Browse Source
* commit 'cad0a13b56b0d0ef2d84ea515198ba80a4df17d1': (32 commits) REPORT-3163 合作开发9.0设计器=>左侧可伸缩面板调整按钮位置 REPORT-2897 9.0设计器修改 PMD REPORT-2897 9.0设计器修改 PMD REPORT-3163 合作开发9.0设计器=>修正一处错误 REPORT-3163 合作开发9.0设计器=>pmd REPORT-2897 9.0设计器修改 缩放条部分 REPORT-3163 合作开发9.0设计器=>左侧可伸缩面板改回原有设计 REPORT-2897 9.0设计器修改 缩放条部分 REPORT-2897 9.0设计器修改 缩放条部分 REPORT-3163 合作开发9.0设计器=>属性面板tab项动态变化(权限编辑) REPORT-3163 合作开发9.0设计器=>属性面板tab项动态变化(聚合报表部分) REPORT-3163 合作开发9.0设计器=>属性面板tab项动态变化(部分) REPORT-2897 9.0设计器修改 缩放条部分 REPORT-3163 合作开发9.0设计器=>propertyItemList 改为 propertyItemMap(有序map) REPORT-3163 合作开发9.0设计器=>所有tab弹出后,显示“无可用配置项” REPORT-3163 合作开发9.0设计器=>交换弹出工具条的上下按钮 REPORT-3163 合作开发9.0设计器=>红色标出可拖动区域 REPORT-3163 合作开发9.0设计器=>面板标题国际化 REPORT-3163 合作开发9.0设计器=>修复弹窗bug:1、失焦后被设计器覆盖;2、弹出后,点击不同单元格,面板没有更新;3、弹出后,点击不同单元格,弹回,面板消失;4、切换面板时,内容不应被遮挡 REPORT-3163 合作开发9.0设计器=>弹出对话框可调整高度 ...master
superman
7 years ago
48 changed files with 3342 additions and 933 deletions
@ -1 +1 @@
|
||||
package com.fr.design.actions;
import com.fr.base.BaseUtils;
import com.fr.design.constants.UIConstants;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.roleAuthority.ReportAndFSManagePane;
import com.fr.design.roleAuthority.RolesAlreadyEditedPane;
import com.fr.design.designer.TargetComponent;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.*;
/**
* Author : daisy
* Date: 13-8-30
* Time: 上午10:12
*/
public class AllowAuthorityEditAction extends TemplateComponentAction {
public AllowAuthorityEditAction(TargetComponent t) {
super(t);
this.setMenuKeySet(KeySetUtils.ALLOW_AUTHORITY_EDIT);
this.setName(getMenuKeySet().getMenuName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/allow_authority_edit.png"));
}
/**
* 撤销
*/
public void prepare4Undo() {
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().iniAuthorityUndoState();
}
/**
* 执行动作
*
* @return 是否执行成功
*/
public boolean executeActionReturnUndoRecordNeeded() {
TargetComponent tc = getEditingComponent();
if (tc == null) {
return false;
}
cleanAuthorityCondition();
//进入时是格式刷则取消格式刷
if (DesignerContext.getFormatState() != DesignerContext.FORMAT_STATE_NULL) {
tc.cancelFormat();
}
BaseUtils.setAuthorityEditing(true);
ReportAndFSManagePane.getInstance().refreshDockingView();
RolesAlreadyEditedPane.getInstance().refreshDockingView();
WestRegionContainerPane.getInstance().replaceDownPane(ReportAndFSManagePane.getInstance());
DesignerContext.getDesignerFrame().setCloseMode(UIConstants.CLOSE_OF_AUTHORITY);
DesignerContext.getDesignerFrame().resetToolkitByPlus(tc.getToolBarMenuDockPlus());
DesignerContext.getDesignerFrame().needToAddAuhtorityPaint();
EastRegionContainerPane.getInstance().replaceUpPane(tc.getEastUpPane());
DesignerContext.getDesignerFrame().refreshDottedLine();
EastRegionContainerPane.getInstance().replaceDownPane(RolesAlreadyEditedPane.getInstance());
EastRegionContainerPane.getInstance().removeParameterPane();
//画虚线
return true;
}
/**
* 进入权限编辑之前将权限编辑界面重置一下工具栏
*/
private void cleanAuthorityCondition() {
java.util.List<JTemplate<?, ?>> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList();
for (int i = 0; i < opendedTemplate.size(); i++) {
opendedTemplate.get(i).cleanAuthorityUndo();
}
}
} |
||||
package com.fr.design.actions;
import com.fr.base.BaseUtils;
import com.fr.design.constants.UIConstants;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.roleAuthority.ReportAndFSManagePane;
import com.fr.design.roleAuthority.RolesAlreadyEditedPane;
import com.fr.design.designer.TargetComponent;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.*;
/**
* Author : daisy
* Date: 13-8-30
* Time: 上午10:12
*/
public class AllowAuthorityEditAction extends TemplateComponentAction {
public AllowAuthorityEditAction(TargetComponent t) {
super(t);
this.setMenuKeySet(KeySetUtils.ALLOW_AUTHORITY_EDIT);
this.setName(getMenuKeySet().getMenuName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/allow_authority_edit.png"));
}
/**
* 撤销
*/
public void prepare4Undo() {
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().iniAuthorityUndoState();
}
/**
* 执行动作
*
* @return 是否执行成功
*/
public boolean executeActionReturnUndoRecordNeeded() {
TargetComponent tc = getEditingComponent();
if (tc == null) {
return false;
}
cleanAuthorityCondition();
//进入时是格式刷则取消格式刷
if (DesignerContext.getFormatState() != DesignerContext.FORMAT_STATE_NULL) {
tc.cancelFormat();
}
BaseUtils.setAuthorityEditing(true);
ReportAndFSManagePane.getInstance().refreshDockingView();
RolesAlreadyEditedPane.getInstance().refreshDockingView();
WestRegionContainerPane.getInstance().replaceDownPane(ReportAndFSManagePane.getInstance());
DesignerContext.getDesignerFrame().setCloseMode(UIConstants.CLOSE_OF_AUTHORITY);
DesignerContext.getDesignerFrame().resetToolkitByPlus(tc.getToolBarMenuDockPlus());
DesignerContext.getDesignerFrame().needToAddAuhtorityPaint();
EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.AUTHORITY_EDITION);
EastRegionContainerPane.getInstance().replaceAuthorityEditionPane(tc.getEastUpPane());
DesignerContext.getDesignerFrame().refreshDottedLine();
EastRegionContainerPane.getInstance().replaceConfiguredRolesPane(RolesAlreadyEditedPane.getInstance());
EastRegionContainerPane.getInstance().removeParameterPane();
//画虚线
return true;
}
/**
* 进入权限编辑之前将权限编辑界面重置一下工具栏
*/
private void cleanAuthorityCondition() {
java.util.List<JTemplate<?, ?>> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList();
for (int i = 0; i < opendedTemplate.size(); i++) {
opendedTemplate.get(i).cleanAuthorityUndo();
}
}
} |
@ -0,0 +1,111 @@
|
||||
package com.fr.design.foldablepane; |
||||
|
||||
import com.fr.design.constants.UIConstants; |
||||
|
||||
import java.awt.*; |
||||
import java.awt.image.BufferedImage; |
||||
import javax.swing.JPanel; |
||||
|
||||
/** |
||||
* Created by MoMeak on 2017/7/5. |
||||
*/ |
||||
public class HeaderPane extends JPanel { |
||||
private static final long serialVersionUID = 1L; |
||||
private int headWidth = 280; |
||||
private int headHeight = 25; |
||||
private Color bgColor; |
||||
private boolean isShow; |
||||
private String title; |
||||
private Image image; |
||||
private int fontSize = 13; |
||||
public void setShow(boolean isShow) { |
||||
this.isShow = isShow; |
||||
} |
||||
|
||||
public void setTitle(String title) |
||||
{ |
||||
this.title = title; |
||||
} |
||||
|
||||
public void setHeadWidth(int headwidth){ |
||||
this.headWidth = headwidth; |
||||
} |
||||
|
||||
public void setheadHeight(int headHeight){ |
||||
this.headHeight = headHeight; |
||||
} |
||||
|
||||
public void setFontSize(int fontSize){ |
||||
this.fontSize = fontSize; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
protected void paintComponent(Graphics g) { |
||||
Graphics2D g2d = (Graphics2D) g.create(); |
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, |
||||
RenderingHints.VALUE_ANTIALIAS_ON); |
||||
BufferedImage panelImage = createPanelImage(); |
||||
g2d.drawImage(panelImage, null, 0, 0); |
||||
} |
||||
|
||||
private BufferedImage createPanelImage() { |
||||
BufferedImage panelImage = new BufferedImage(getWidth(), headHeight, BufferedImage.TYPE_INT_ARGB); |
||||
Graphics2D g2d = panelImage.createGraphics(); |
||||
|
||||
g2d.fillRect(0, 0, headWidth, headHeight); |
||||
g2d.drawImage(UIConstants.DRAG_BAR, 0, 0, headWidth, headHeight, null); |
||||
g2d.setFont(new Font("SimSun", 0, fontSize)); |
||||
g2d.setPaint(bgColor); |
||||
// g2d.drawString(this.title, fontSize/2, headHeight-fontSize/3);
|
||||
g2d.drawString(this.title, 0, headHeight-fontSize/3); |
||||
if(this.isShow) |
||||
{ |
||||
image = UIConstants.DRAG_DOWN_PRESS; |
||||
g2d.drawImage(image, title.length() * fontSize, headHeight/2-1, null); |
||||
} |
||||
else |
||||
{ |
||||
image = UIConstants.DRAG_RIGHT_PRESS; |
||||
g2d.drawImage(image, title.length() * fontSize, headHeight/3, null); |
||||
} |
||||
|
||||
|
||||
return panelImage; |
||||
} |
||||
|
||||
@Override |
||||
public Dimension getPreferredSize() { |
||||
return new Dimension(this.getWidth(), headHeight); |
||||
} |
||||
|
||||
@Override |
||||
public Dimension getSize() { |
||||
return new Dimension(this.getWidth(), headHeight); |
||||
} |
||||
|
||||
public HeaderPane(Color bgColor) { |
||||
this.bgColor = bgColor; |
||||
this.isShow = true; |
||||
|
||||
} |
||||
|
||||
public HeaderPane(Color bgColor, String title , int headWidth, int headHeight) { |
||||
this(bgColor); |
||||
this.title = title; |
||||
this.headHeight = headHeight; |
||||
this.headWidth = headWidth; |
||||
} |
||||
|
||||
public static void main(String[] args) |
||||
{ |
||||
// JFrame mainFrame = new JFrame("UI Demo - Gloomyfish");
|
||||
// mainFrame.getContentPane().setLayout(new BorderLayout());
|
||||
// mainFrame.getContentPane().add(new HeaderPane(Color.black, "基本",280,25), BorderLayout.CENTER);
|
||||
// mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
// mainFrame.pack();
|
||||
// mainFrame.setSize(280, 400);
|
||||
// mainFrame.setVisible(true);
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,95 @@
|
||||
package com.fr.design.foldablepane; |
||||
|
||||
import java.awt.*; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
|
||||
import javax.swing.*; |
||||
|
||||
|
||||
/** |
||||
* Created by MoMeak on 2017/7/5. |
||||
*/ |
||||
public class UIExpandablePane extends JPanel { |
||||
private static final long serialVersionUID = 1L; |
||||
private HeaderPane headerPanel; |
||||
private JPanel contentPanel; |
||||
private Color color = Color.black; |
||||
private String title; |
||||
private int headWidth; |
||||
private int headHeight; |
||||
|
||||
|
||||
public UIExpandablePane(String title,int headWidth,int headHeight,JPanel contentPanel) |
||||
{ |
||||
super(); |
||||
this.title = title; |
||||
this.headWidth = headWidth; |
||||
this.headHeight = headHeight; |
||||
this.contentPanel = contentPanel; |
||||
initComponents(); |
||||
} |
||||
|
||||
private void initComponents() { |
||||
this.setLayout(new BorderLayout()); |
||||
|
||||
headerPanel = new HeaderPane(color, title,headWidth,headHeight); |
||||
headerPanel.addMouseListener(new PanelAction()); |
||||
this.add(headerPanel, BorderLayout.NORTH); |
||||
this.add(contentPanel, BorderLayout.CENTER); |
||||
setOpaque(false); |
||||
} |
||||
|
||||
class PanelAction extends MouseAdapter |
||||
{ |
||||
public void mousePressed(MouseEvent e) |
||||
{ |
||||
HeaderPane hp = (HeaderPane)e.getSource(); |
||||
if(contentPanel.isShowing()) |
||||
{ |
||||
contentPanel.setVisible(false); |
||||
hp.setShow(false); |
||||
} |
||||
else |
||||
{ |
||||
contentPanel.setVisible(true); |
||||
hp.setShow(true); |
||||
} |
||||
hp.getParent().validate(); |
||||
hp.getParent().repaint(); |
||||
} |
||||
} |
||||
|
||||
|
||||
public static void main(String[] args) |
||||
{ |
||||
// JFrame jf = new JFrame("test");
|
||||
// jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
// JPanel content = (JPanel) jf.getContentPane();
|
||||
// content.setLayout(new BorderLayout());
|
||||
//
|
||||
// JPanel myPanel = new JPanel();
|
||||
// myPanel.setLayout(new BorderLayout());
|
||||
// JPanel Panel = new JPanel();
|
||||
// Panel.setBackground(Color.blue);
|
||||
// myPanel.add(new UIExpandablePane("基本",280,25,Panel),BorderLayout.CENTER);
|
||||
//// myPanel.setLayout(new GridBagLayout());
|
||||
//// myPanel.add(new JExpandablePanel());
|
||||
//// GridBagConstraints gbc = new GridBagConstraints();
|
||||
//// JPanel[] panels = new JPanel[4]; //
|
||||
//// gbc.insets = new Insets(1,3,0,3);
|
||||
//// gbc.weightx = 1.0;
|
||||
//// gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
//// gbc.gridwidth = GridBagConstraints.REMAINDER;
|
||||
//// for(int j = 0; j < panels.length; j++)
|
||||
//// {
|
||||
//// panels[j] = new JExpandablePanel();
|
||||
//// myPanel.add(panels[j], gbc);
|
||||
//// }
|
||||
// content.add(myPanel, BorderLayout.CENTER);
|
||||
// GUICoreUtils.centerWindow(jf);
|
||||
// jf.setSize(280, 400);
|
||||
// jf.setVisible(true);
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,310 @@
|
||||
package com.fr.design.gui.icontainer; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.constants.UIConstants; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
import com.fr.stable.Constants; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
import java.awt.event.MouseMotionListener; |
||||
|
||||
/** |
||||
* Created by plough on 2017/7/7. |
||||
*/ |
||||
public class UIEastResizableContainer extends JPanel { |
||||
private static final long serialVersionUID = 1854340560790476907L; |
||||
private int containerWidth = 240; |
||||
private int preferredWidth = 240; |
||||
private int topToolPaneHeight = 20; |
||||
private int leftPaneWidth = 40; |
||||
|
||||
private JComponent leftPane; |
||||
private JComponent rightPane; |
||||
|
||||
// private HorizotalToolPane horizontToolPane;
|
||||
private TopToolPane topToolPane; |
||||
|
||||
|
||||
private static final int ARROW_MARGIN = 15; |
||||
private static final int ARROW_RANGE = 35; |
||||
|
||||
// private boolean isRightPaneVisible = true;
|
||||
|
||||
public UIEastResizableContainer() { |
||||
this(new JPanel(), new JPanel()); |
||||
} |
||||
|
||||
/** |
||||
* 设置面板宽度 |
||||
* |
||||
* @param width |
||||
*/ |
||||
public void setContainerWidth(int width) { |
||||
this.containerWidth = width; |
||||
this.preferredWidth = width; |
||||
} |
||||
|
||||
public boolean isRightPaneVisible() { |
||||
return containerWidth > leftPaneWidth; |
||||
} |
||||
|
||||
|
||||
// public void setRightPaneVisible(boolean isVisible){
|
||||
// this.isRightPaneVisible = isVisible;
|
||||
// }
|
||||
|
||||
private void setPreferredWidth(int width) { |
||||
this.preferredWidth = width; |
||||
} |
||||
|
||||
public UIEastResizableContainer(JComponent leftPane, JComponent rightPane) { |
||||
setBackground(UIConstants.NORMAL_BACKGROUND); |
||||
this.leftPane = leftPane; |
||||
this.rightPane = rightPane; |
||||
|
||||
this.topToolPane = new TopToolPane(); |
||||
|
||||
setLayout(containerLayout); |
||||
add(topToolPane); |
||||
add(leftPane); |
||||
add(rightPane); |
||||
} |
||||
|
||||
public static void main(String... args) { |
||||
JFrame jf = new JFrame("test"); |
||||
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
||||
JPanel content = (JPanel) jf.getContentPane(); |
||||
content.setLayout(new BorderLayout()); |
||||
|
||||
JPanel leftPane = new JPanel(); |
||||
leftPane.setBackground(Color.yellow); |
||||
JPanel rightPane = new JPanel(); |
||||
rightPane.setBackground(Color.green); |
||||
|
||||
UIButton b1, b2; |
||||
b1 = new UIButton("b1"); |
||||
b2 = new UIButton("b2"); |
||||
b1.setPreferredSize(new Dimension(40, 40)); |
||||
b2.setPreferredSize(new Dimension(40, 40)); |
||||
leftPane.add(b1); |
||||
leftPane.add(b2); |
||||
|
||||
|
||||
UIEastResizableContainer bb = new UIEastResizableContainer(leftPane, rightPane); |
||||
|
||||
JPanel cc = new JPanel(); |
||||
cc.setBackground(Color.white); |
||||
|
||||
content.add(bb, BorderLayout.EAST); |
||||
content.add(cc, BorderLayout.CENTER); |
||||
GUICoreUtils.centerWindow(jf); |
||||
jf.setSize(500, 500); |
||||
jf.setVisible(true); |
||||
} |
||||
|
||||
/** |
||||
* 将面板设置成最佳的宽度 |
||||
*/ |
||||
public void setWindow2PreferWidth() { |
||||
if (containerWidth == leftPaneWidth) { |
||||
containerWidth = preferredWidth; |
||||
refreshContainer(); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 得到容器的宽度 |
||||
* |
||||
* @return |
||||
*/ |
||||
public int getContainerWidth() { |
||||
return this.containerWidth; |
||||
} |
||||
|
||||
/** |
||||
* 设置关闭设计器前最后一次面板的宽度 |
||||
* |
||||
* @param containerWidth |
||||
*/ |
||||
public void setLastContainerWidth(int containerWidth) { |
||||
this.containerWidth = containerWidth; |
||||
} |
||||
|
||||
private LayoutManager containerLayout = new LayoutManager() { |
||||
|
||||
@Override |
||||
public void removeLayoutComponent(Component comp) { |
||||
// TODO Auto-generated method stub
|
||||
|
||||
} |
||||
|
||||
@Override |
||||
public Dimension preferredLayoutSize(Container parent) { |
||||
return parent.getPreferredSize(); |
||||
} |
||||
|
||||
@Override |
||||
public Dimension minimumLayoutSize(Container parent) { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void layoutContainer(Container parent) { |
||||
if (topToolPane == null || rightPane == null) { |
||||
return; |
||||
} |
||||
|
||||
topToolPane.setBounds(0, 0, containerWidth, topToolPaneHeight);//0,0,10,462
|
||||
leftPane.setBounds(0, topToolPaneHeight, leftPaneWidth, getHeight() - topToolPaneHeight); |
||||
|
||||
// parameterPane.setBounds(20, 0, 230, getParameterPaneHeight());//10,0,230,462
|
||||
rightPane.setBounds(leftPaneWidth, topToolPaneHeight, containerWidth-leftPaneWidth, getHeight() - topToolPaneHeight);//20,0,230,0
|
||||
} |
||||
|
||||
@Override |
||||
public void addLayoutComponent(String name, Component comp) { |
||||
} |
||||
}; |
||||
|
||||
@Override |
||||
/** |
||||
* 得到最佳大小 |
||||
*/ |
||||
public Dimension getPreferredSize() { |
||||
return new Dimension(containerWidth, 400); |
||||
} |
||||
|
||||
/** |
||||
* 替换左子面板 |
||||
* |
||||
* @param pane 面板 |
||||
*/ |
||||
public void replaceLeftPane(JComponent pane) { |
||||
remove(pane); |
||||
remove(this.leftPane); |
||||
add(this.leftPane = pane); |
||||
refreshContainer(); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 替换右子面板 |
||||
* |
||||
* @param pane 面板 |
||||
*/ |
||||
public void replaceRightPane(JComponent pane) { |
||||
remove(pane); |
||||
remove(this.rightPane); |
||||
add(this.rightPane = pane); |
||||
refreshContainer(); |
||||
} |
||||
|
||||
/** |
||||
* 得到左子面板 |
||||
* |
||||
* @return |
||||
*/ |
||||
public JComponent getLeftPane() { |
||||
return this.leftPane; |
||||
} |
||||
|
||||
/** |
||||
* 得到右子面板 |
||||
* |
||||
* @return |
||||
*/ |
||||
public JComponent getRightPane() { |
||||
return this.rightPane; |
||||
} |
||||
|
||||
private void refreshContainer() { |
||||
validate(); |
||||
repaint(); |
||||
revalidate(); |
||||
} |
||||
|
||||
/** |
||||
* 伸缩右子面板时,触发此方法 |
||||
*/ |
||||
public void onResize() { |
||||
} |
||||
|
||||
private class TopToolPane extends JPanel { |
||||
private int model = UIConstants.MODEL_NORMAL; |
||||
|
||||
public TopToolPane() { |
||||
super(); |
||||
addMouseMotionListener(new MouseMotionListener() { |
||||
|
||||
@Override |
||||
public void mouseMoved(MouseEvent e) { |
||||
if (e.getX() <= ARROW_RANGE) { |
||||
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
||||
model = UIConstants.MODEL_PRESS; |
||||
} else { |
||||
setCursor(Cursor.getDefaultCursor()); |
||||
model = UIConstants.MODEL_NORMAL; |
||||
} |
||||
repaint(); |
||||
} |
||||
|
||||
@Override |
||||
public void mouseDragged(MouseEvent e) { |
||||
} |
||||
}); |
||||
addMouseListener(new MouseAdapter() { |
||||
@Override |
||||
public void mouseExited(MouseEvent e) { |
||||
setCursor(Cursor.getDefaultCursor()); |
||||
model = UIConstants.MODEL_NORMAL; |
||||
repaint(); |
||||
} |
||||
|
||||
@Override |
||||
public void mouseClicked(MouseEvent e) { |
||||
if (e.getX() <= ARROW_RANGE) { |
||||
if (containerWidth == leftPaneWidth) { |
||||
containerWidth = preferredWidth; |
||||
} else { |
||||
setPreferredWidth(containerWidth); |
||||
containerWidth = leftPaneWidth; |
||||
} |
||||
onResize(); |
||||
refreshContainer(); |
||||
if (BaseUtils.isAuthorityEditing()) { |
||||
DesignerContext.getDesignerFrame().doResize(); |
||||
} |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@Override |
||||
public void paint(Graphics g) { |
||||
Image button; |
||||
|
||||
g.drawImage(UIConstants.DRAG_BAR, 0, 0, containerWidth, topToolPaneHeight, null); |
||||
if (containerWidth == leftPaneWidth) { |
||||
if (model == UIConstants.MODEL_NORMAL) { |
||||
button = UIConstants.DRAG_LEFT_NORMAL; |
||||
} else { |
||||
button = UIConstants.DRAG_LEFT_PRESS; |
||||
} |
||||
} else { |
||||
if (model == UIConstants.MODEL_NORMAL) { |
||||
button = UIConstants.DRAG_RIGHT_NORMAL; |
||||
} else { |
||||
button = UIConstants.DRAG_RIGHT_PRESS; |
||||
} |
||||
} |
||||
// g.drawImage(button, 2, ARROW_MARGIN_VERTICAL, 5, toolPaneHeight, null);
|
||||
g.drawImage(button, 20, 7, 5, 5, null); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,417 @@
|
||||
package com.fr.design.mainframe; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.ibutton.UIRadioButton; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.islider.UISlider; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
import com.fr.general.Inter; |
||||
|
||||
import javax.swing.*; |
||||
import javax.swing.border.MatteBorder; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.event.ChangeListener; |
||||
import javax.swing.event.DocumentEvent; |
||||
import javax.swing.event.DocumentListener; |
||||
import javax.swing.plaf.basic.BasicSliderUI; |
||||
import java.awt.*; |
||||
import java.awt.event.*; |
||||
import java.math.BigDecimal; |
||||
|
||||
/** |
||||
* Created by MoMeak on 2017/7/13. |
||||
*/ |
||||
public class JSliderPane extends JPanel { |
||||
|
||||
private static final double ONEPOINTEIGHT = 1.8; |
||||
private static final int SIX = 6; |
||||
private static final int TEN = 10; |
||||
private static final int ONEEIGHT = 18; |
||||
private static final int FOURTEN = 40; |
||||
private static final int HALFHUNDRED = 50; |
||||
private static final int HUNDRED = 100; |
||||
private static final int TWOHUNDRED = 200; |
||||
private static final int THREEHUNDRED = 300; |
||||
private static final int FOURHUNDRED = 400; |
||||
private static final int DIALOGWIDTH = 150; |
||||
private static final int DIALOGHEIGHT = 200; |
||||
public int showValue = 100; |
||||
public double resolutionTimes = 1.0; |
||||
private static JSliderPane THIS; |
||||
private UITextField showVal; |
||||
private UISlider slider; |
||||
private int times; |
||||
private int sliderValue; |
||||
private UIButton downButton; |
||||
private UIButton upButton; |
||||
private UIButton showValButton; |
||||
private UIRadioButton twoHundredButton; |
||||
private UIRadioButton oneHundredButton; |
||||
private UIRadioButton SevenFiveButton; |
||||
private UIRadioButton fiveTenButton; |
||||
private UIRadioButton twoFiveButton; |
||||
private UIRadioButton selfAdaptButton; |
||||
private UIRadioButton customButton; |
||||
//拖动条处理和button、直接输入不一样
|
||||
private boolean isButtonOrIsTxt = true; |
||||
private PopupPane dialog; |
||||
private int upButtonX; |
||||
|
||||
|
||||
public JSliderPane() { |
||||
this.setLayout(new BorderLayout()); |
||||
slider = new UISlider(0,HUNDRED,HALFHUNDRED); |
||||
slider.setUI(new JSliderPaneUI(slider)); |
||||
slider.addChangeListener(listener); |
||||
|
||||
showVal = new UITextField(); |
||||
showVal.setText("100%"); |
||||
showVal.setPreferredSize(new Dimension(FOURTEN,ONEEIGHT)); |
||||
showVal.getDocument().addDocumentListener(showValDocumentListener); |
||||
|
||||
downButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/moveDown.png")); |
||||
upButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/moveUp.png")); |
||||
downButton.setActionCommand("less"); |
||||
upButton.setActionCommand("more"); |
||||
downButton.addActionListener(buttonActionListener); |
||||
upButton.addActionListener(buttonActionListener); |
||||
|
||||
JPanel panel = new JPanel(new FlowLayout(1,1,0)); |
||||
|
||||
showValButton = new UIButton(showVal.getText()); |
||||
showValButton.setBorderPainted(false); |
||||
showValButton.setPreferredSize(new Dimension(HALFHUNDRED,ONEEIGHT)); |
||||
|
||||
showValButton.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
popupDialog(); |
||||
} |
||||
}); |
||||
panel.add(downButton); |
||||
panel.add(slider); |
||||
panel.add(upButton); |
||||
panel.add(showValButton); |
||||
this.add(panel,BorderLayout.NORTH); |
||||
this.setBounds(0,0,THREEHUNDRED,ONEEIGHT); |
||||
|
||||
} |
||||
|
||||
public static final JSliderPane getInstance() { |
||||
// if (THIS == null) {
|
||||
// THIS = new JSliderPane();
|
||||
// }
|
||||
THIS = new JSliderPane(); |
||||
return THIS; |
||||
} |
||||
|
||||
private void initUIRadioButton(){ |
||||
twoHundredButton = new UIRadioButton("200%"); |
||||
oneHundredButton = new UIRadioButton("100%"); |
||||
SevenFiveButton = new UIRadioButton("75%"); |
||||
fiveTenButton = new UIRadioButton("50%"); |
||||
twoFiveButton = new UIRadioButton("25%"); |
||||
selfAdaptButton = new UIRadioButton(Inter.getLocText("FR-Designer_Scale_selfAdaptButton")); |
||||
customButton = new UIRadioButton(Inter.getLocText("FR-Designer_Scale_customButton")); |
||||
|
||||
ButtonGroup bg=new ButtonGroup();// 初始化按钮组
|
||||
bg.add(twoHundredButton);// 加入按钮组
|
||||
bg.add(oneHundredButton); |
||||
bg.add(SevenFiveButton); |
||||
bg.add(fiveTenButton); |
||||
bg.add(twoFiveButton); |
||||
bg.add(selfAdaptButton); |
||||
bg.add(customButton); |
||||
} |
||||
|
||||
|
||||
//定义一个监听器,用于监听所有滑动条
|
||||
ChangeListener listener = new ChangeListener() |
||||
{ |
||||
public void stateChanged( ChangeEvent event) { |
||||
//取出滑动条的值,并在文本中显示出来
|
||||
if (!isButtonOrIsTxt){ |
||||
JSlider source = (JSlider) event.getSource(); |
||||
EventQueue.invokeLater(new Runnable() { |
||||
public void run() { |
||||
sliderValue = slider.getValue(); |
||||
getTimes(sliderValue); |
||||
showValue = times; |
||||
showVal.setText(times + "%"); |
||||
} |
||||
}); |
||||
}else { |
||||
isButtonOrIsTxt = false; |
||||
} |
||||
} |
||||
}; |
||||
|
||||
DocumentListener showValDocumentListener = new DocumentListener() { |
||||
@Override |
||||
public void insertUpdate(DocumentEvent e) { |
||||
isButtonOrIsTxt = true; |
||||
resolutionTimes = divide(showValue,100,2); |
||||
refreshSlider(); |
||||
refreshBottun(); |
||||
} |
||||
|
||||
@Override |
||||
public void removeUpdate(DocumentEvent e) { |
||||
// refreshSlider();
|
||||
} |
||||
|
||||
@Override |
||||
public void changedUpdate(DocumentEvent e) { |
||||
// refreshSlider();
|
||||
} |
||||
}; |
||||
|
||||
private void refreshSlider(){ |
||||
showValue = Integer.parseInt(showVal.getText().substring(0, showVal.getText().indexOf("%"))); |
||||
if (showValue >HUNDRED){ |
||||
slider.setValue((int)(showValue+TWOHUNDRED)/SIX); |
||||
}else if (showValue <HUNDRED){ |
||||
slider.setValue((int)((showValue-TEN)/ONEPOINTEIGHT)); |
||||
}else if (showValue == HUNDRED){ |
||||
slider.setValue(HALFHUNDRED); |
||||
} |
||||
} |
||||
|
||||
|
||||
private void refreshBottun(){ |
||||
showValButton.setText(showVal.getText()); |
||||
} |
||||
|
||||
public double getResolutionTimes(){ |
||||
return this.resolutionTimes; |
||||
} |
||||
|
||||
public int getshowValue(){ |
||||
return this.showValue; |
||||
} |
||||
|
||||
public static double divide(double v1, double v2,int scale) { |
||||
BigDecimal b1 = new BigDecimal(Double.toString(v1)); |
||||
BigDecimal b2 = new BigDecimal(Double.toString(v2)); |
||||
return b1.divide(b2,scale).doubleValue(); |
||||
} |
||||
|
||||
ActionListener buttonActionListener = new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
showValue = Integer.parseInt(showVal.getText().substring(0, showVal.getText().indexOf("%"))); |
||||
isButtonOrIsTxt = true; |
||||
if(e.getActionCommand().equals("less")){ |
||||
int newDownVal = showValue - TEN; |
||||
if (newDownVal >= TEN ){ |
||||
showValue = newDownVal; |
||||
showVal.setText(newDownVal + "%"); |
||||
}else { |
||||
showValue = newDownVal; |
||||
showVal.setText(TEN + "%"); |
||||
} |
||||
} |
||||
if(e.getActionCommand().equals("more")){ |
||||
int newUpVal = showValue + TEN; |
||||
if (newUpVal <= FOURHUNDRED ){ |
||||
showValue = newUpVal; |
||||
showVal.setText(newUpVal + "%"); |
||||
}else { |
||||
showValue = newUpVal; |
||||
showVal.setText(FOURHUNDRED + "%"); |
||||
} |
||||
} |
||||
isButtonOrIsTxt = true; |
||||
} |
||||
}; |
||||
|
||||
|
||||
|
||||
private void getTimes(int value){ |
||||
if (value == HALFHUNDRED){ |
||||
times=HUNDRED; |
||||
}else if (value < HALFHUNDRED){ |
||||
times = (int) Math.round(ONEPOINTEIGHT*value + TEN); |
||||
}else { |
||||
times = (int) (SIX*value - TWOHUNDRED); |
||||
} |
||||
} |
||||
|
||||
|
||||
public UITextField getShowVal(){ |
||||
return this.showVal; |
||||
} |
||||
|
||||
private void popupDialog(){ |
||||
Point btnCoords = upButton.getLocationOnScreen(); |
||||
if (dialog == null){ |
||||
dialog = new PopupPane(upButton,showVal); |
||||
if (upButtonX == 0) { |
||||
upButtonX = btnCoords.x; |
||||
GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOGWIDTH + upButton.getWidth() +HALFHUNDRED, -DIALOGHEIGHT); |
||||
} |
||||
}else { |
||||
if (upButtonX == 0) { |
||||
upButtonX = btnCoords.x; |
||||
GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOGWIDTH + upButton.getWidth() +HALFHUNDRED, -DIALOGHEIGHT); |
||||
} else { |
||||
GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOGWIDTH + upButton.getWidth() +HALFHUNDRED, -DIALOGHEIGHT); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static void main(String[] args) |
||||
{ |
||||
JFrame jf = new JFrame("test"); |
||||
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
||||
JPanel content = (JPanel)jf.getContentPane(); |
||||
content.setLayout(new BorderLayout()); |
||||
content.add(JSliderPane.getInstance(),BorderLayout.CENTER); |
||||
GUICoreUtils.centerWindow(jf); |
||||
jf.setSize(400, 80); |
||||
jf.setVisible(true); |
||||
|
||||
} |
||||
} |
||||
|
||||
class JSliderPaneUI extends BasicSliderUI { |
||||
|
||||
private static final int VERTICAL_WIDTH = 11; |
||||
private static final int VERTICAL_HEIGHT = 16; |
||||
private static final int FOUR = 4; |
||||
private static final int FIVE = 5; |
||||
private static final int SIX = 6; |
||||
|
||||
public JSliderPaneUI(UISlider b) { |
||||
super(b); |
||||
} |
||||
|
||||
/** */ |
||||
/** |
||||
* 绘制指示物 |
||||
*/ |
||||
|
||||
public Dimension getThumbSize() { |
||||
Dimension size = new Dimension(); |
||||
|
||||
if ( slider.getOrientation() == JSlider.VERTICAL ) { |
||||
size.width = VERTICAL_WIDTH; |
||||
size.height = VERTICAL_HEIGHT; |
||||
} |
||||
else { |
||||
size.width = VERTICAL_WIDTH; |
||||
size.height = VERTICAL_HEIGHT; |
||||
} |
||||
|
||||
return size; |
||||
} |
||||
|
||||
public void paintThumb(Graphics g) { |
||||
Rectangle knobBounds = thumbRect; |
||||
int w = knobBounds.width; |
||||
int h = knobBounds.height; |
||||
|
||||
g.translate(knobBounds.x, knobBounds.y); |
||||
if ( slider.isEnabled() ) { |
||||
g.setColor(slider.getBackground()); |
||||
} |
||||
else { |
||||
g.setColor(slider.getBackground().darker()); |
||||
} |
||||
g.setColor(Color.darkGray); |
||||
g.fillRect(0, 1, w-SIX, h+1); |
||||
} |
||||
|
||||
/** */ |
||||
/** |
||||
* 绘制刻度轨迹 |
||||
*/ |
||||
public void paintTrack(Graphics g) { |
||||
int cy, cw; |
||||
Rectangle trackBounds = trackRect; |
||||
if (slider.getOrientation() == UISlider.HORIZONTAL) { |
||||
Graphics2D g2 = (Graphics2D) g; |
||||
cy = (trackBounds.height / 2); |
||||
cw = trackBounds.width; |
||||
g.setColor(Color.lightGray); |
||||
g.drawLine(0, cy, cw+FIVE, cy); |
||||
g.drawLine(FIVE+cw/2, cy-FOUR, FIVE+cw/2, cy+FOUR); |
||||
} else { |
||||
super.paintTrack(g); |
||||
} |
||||
} |
||||
|
||||
} |
||||
class Dialog extends JDialog { |
||||
// private Container container;
|
||||
// private static final int UPLABELHEIGHT = 25;
|
||||
// private static final int HALFHUNDRED = 50;
|
||||
// private static final int DIALOGWIDTH = 150;
|
||||
// private static final int DIALOGHEIGHT = 200;
|
||||
// private static final int UPLABELWIDTH = 300;
|
||||
// private int minHeight; // 对话框最小高度
|
||||
// private JComponent contentPane;
|
||||
// private JComponent centerPane;
|
||||
// private UILabel upLabel;
|
||||
|
||||
// public Dialog(UIButton b,UITextField j) {
|
||||
// super(DesignerContext.getDesignerFrame());
|
||||
// container = getContentPane();
|
||||
// setUndecorated(true);
|
||||
// contentPane = new JPanel(new BorderLayout());
|
||||
// centerPane = new JPanel(new BorderLayout());
|
||||
// upLabel = new UILabel(Inter.getLocText("FR-Designer_Scale_EnlargeOrReduce"));
|
||||
// upLabel.setOpaque(true);
|
||||
// upLabel.setPreferredSize(new Dimension(UPLABELWIDTH,UPLABELHEIGHT));
|
||||
// upLabel.setBackground(Color.LIGHT_GRAY);
|
||||
// upLabel.setBorder(BorderFactory.createLineBorder(Color.gray,1));
|
||||
// upLabel.setBorder(new MatteBorder(0,0,1,0,Color.gray));
|
||||
// centerPane.add(j,BorderLayout.NORTH);
|
||||
// contentPane.add(upLabel,BorderLayout.NORTH);
|
||||
// contentPane.add(centerPane,BorderLayout.CENTER);
|
||||
//// contentPane.setBorder(BorderFactory.createLineBorder(Color.gray,1));
|
||||
// contentPane.setBorder(new MatteBorder(1,1,1,1,Color.darkGray));
|
||||
//// contentPane.add(new JPanel())
|
||||
// container.add(contentPane, BorderLayout.CENTER);
|
||||
// minHeight = container.getPreferredSize().height;
|
||||
// setSize(DIALOGWIDTH, DIALOGHEIGHT);
|
||||
//// validate();
|
||||
// Point btnCoords = b.getLocationOnScreen();
|
||||
//
|
||||
// this.setLocation(btnCoords.x - DIALOGWIDTH + b.getWidth() +HALFHUNDRED, btnCoords.y -DIALOGHEIGHT);
|
||||
//// initListener();
|
||||
//
|
||||
// this.setVisible(true);
|
||||
// }
|
||||
} |
||||
class PopupPane extends JPopupMenu { |
||||
private JComponent contentPane; |
||||
private static final int UPLABELHEIGHT = 25; |
||||
private static final int HALFHUNDRED = 50; |
||||
private static final int DIALOGWIDTH = 150; |
||||
private static final int DIALOGHEIGHT = 200; |
||||
private static final int UPLABELWIDTH = 300; |
||||
private JComponent centerPane; |
||||
private UILabel upLabel; |
||||
PopupPane(UIButton b,UITextField j) { |
||||
contentPane = new JPanel(new BorderLayout()); |
||||
centerPane = new JPanel(new BorderLayout()); |
||||
upLabel = new UILabel(Inter.getLocText("FR-Designer_Scale_EnlargeOrReduce")); |
||||
upLabel.setOpaque(true); |
||||
upLabel.setPreferredSize(new Dimension(UPLABELWIDTH,UPLABELHEIGHT)); |
||||
upLabel.setBackground(Color.LIGHT_GRAY); |
||||
upLabel.setBorder(new MatteBorder(0,0,1,0,Color.gray)); |
||||
centerPane.add(j,BorderLayout.NORTH); |
||||
contentPane.add(upLabel,BorderLayout.NORTH); |
||||
contentPane.add(centerPane,BorderLayout.CENTER); |
||||
// contentPane.setBorder(new MatteBorder(1,1,1,1,Color.darkGray));
|
||||
this.add(contentPane, BorderLayout.CENTER); |
||||
this.setPreferredSize(new Dimension(DIALOGWIDTH, DIALOGHEIGHT)); |
||||
this.setOpaque(false); |
||||
} |
||||
|
||||
|
||||
|
||||
} |
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue