You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
2.2 KiB
96 lines
2.2 KiB
package com.fr.design.report.freeze; |
|
|
|
import java.awt.Dimension; |
|
import javax.swing.JComponent; |
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import javax.swing.event.ChangeEvent; |
|
import javax.swing.event.ChangeListener; |
|
import com.fr.design.beans.BasicBeanPane; |
|
import com.fr.design.gui.ispinner.UISpinner; |
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
import com.fr.stable.FT; |
|
|
|
/** |
|
* 重复与冻结 |
|
* |
|
* @author Daniel~ |
|
* |
|
*/ |
|
public abstract class FreezeAndRepeatPane extends BasicBeanPane<FT> { |
|
protected JComponent start; |
|
protected JComponent end; |
|
|
|
protected UILabel connectionLabel; |
|
|
|
protected boolean isEnalbed; |
|
|
|
protected void initComponent() { |
|
Dimension size = new Dimension(43, 21); |
|
if (start instanceof UISpinner) { |
|
start.setPreferredSize(size); |
|
((UISpinner) start).addChangeListener(new ChangeListener() { |
|
@Override |
|
public void stateChanged(ChangeEvent e) { |
|
updateEndValue(); |
|
} |
|
}); |
|
} |
|
if (end instanceof UISpinner) { |
|
end.setPreferredSize(size); |
|
((UISpinner) end).addChangeListener(new ChangeListener() { |
|
@Override |
|
public void stateChanged(ChangeEvent e) { |
|
updateEndValue(); |
|
} |
|
}); |
|
} |
|
this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); |
|
this.add(start); |
|
connectionLabel = new UILabel(getLabeshow()); |
|
this.add(connectionLabel); |
|
this.add(end); |
|
} |
|
|
|
public abstract String getLabeshow(); |
|
|
|
@Override |
|
public void setEnabled(boolean flag) { |
|
this.isEnalbed = flag; |
|
if (start instanceof UISpinner) { |
|
start.setEnabled(flag); |
|
} |
|
if (end instanceof UISpinner) { |
|
end.setEnabled(flag); |
|
} |
|
} |
|
|
|
@Override |
|
/** |
|
* 返回组件是否可用 |
|
*/ |
|
public boolean isEnabled() { |
|
return this.isEnalbed; |
|
} |
|
|
|
/** |
|
* 给UISpinner添加Listener |
|
*/ |
|
public void addListener(ChangeListener l) { |
|
if (start instanceof UISpinner) { |
|
((UISpinner) start).addChangeListener(l); |
|
} |
|
if (end instanceof UISpinner) { |
|
((UISpinner) end).addChangeListener(l); |
|
} |
|
} |
|
|
|
|
|
private void updateEndValue() { |
|
if (end instanceof UISpinner && start instanceof UISpinner) { |
|
((UISpinner) end).setMinValue(((UISpinner) start).getValue()); |
|
((UISpinner) end).setValue(((UISpinner) end).getValue()); |
|
|
|
} |
|
} |
|
} |