@ -1,5 +1,6 @@
package com.fr.design.actions.replace.ui ;
import com.fr.base.svg.IconUtils ;
import com.fr.design.gui.ibutton.UIButton ;
import com.fr.design.gui.icombobox.UIComboBox ;
import com.fr.design.gui.icontainer.UIScrollPane ;
@ -9,7 +10,9 @@ import com.fr.design.i18n.Toolkit;
import com.fr.stable.StringUtils ;
import javax.swing.BorderFactory ;
import javax.swing.ComboBoxEditor ;
import javax.swing.Icon ;
import javax.swing.JCheckBox ;
import javax.swing.JPanel ;
import javax.swing.ScrollPaneConstants ;
@ -34,20 +37,28 @@ public class ITReplaceNorthPanel {
private UIComboBox findCombobox ;
private UIComboBox rangeCombobox ;
private JCheckBox matchRadioButton ;
private UILabel iconLabel ;
private UIComboBox findInputCombobox ;
private UIComboBox replaceInputCombobox ;
private UIScrollPane scrollPane ;
private UIButton replaceButton ;
private UIButton searchButton ;
private static double rate = 1 . 00 ;
//存储的5次最近输入
private int maxItemCount = 5 ;
private static final int LIMIT_WIDTH = 125 0;
private static int limit_width = 80 0;
private static final int HEIGHT = 161 ;
private static final int BUTTON_WIDTH = 60 ;
private static final int BUTTON_GAP = 20 ;
private static final int BUTTON_WIDTH = 44 ;
private static final int GAP = 20 ;
private static final int BUTTON_GAP = 10 ;
private static final int MATCH_WIDTH = 70 ;
private static final int COMPONENT_HEIGHT = 25 ;
private static final int FIRST_Y = 15 , SECOND_Y = 50 , THIRD_Y = 85 , FOURTH_Y = 120 ;
private static final int FIRST_X = 20 , SECOND_X = 80 ;
private static final int LABEL_WIDTH = 60 ;
private static final Icon CHANGE_ICON = IconUtils . readIcon ( "/com/fr/design/images/replace/change_normal.svg" ) ;
private int findLabelX , findLabelY , findLabelWidth , findLabelHeight ;
@ -60,7 +71,8 @@ public class ITReplaceNorthPanel {
private int replaceInputComboBoxX , replaceInputComboBoxY , replaceInputComboBoxWidth , replaceInputComboBoxHeight ;
private int replaceButtonX , replaceButtonY , replaceButtonHeight ;
private int searchButtonX , searchButtonY , searchButtonHeight ;
private int iconX , iconY , iconWidth , iconHeight ;
private int inputLength ;
public static ArrayList < String > findItems = new ArrayList < > ( ) ;
public static ArrayList < String > findInputItems = new ArrayList < > ( ) ;
@ -81,6 +93,7 @@ public class ITReplaceNorthPanel {
findLabel = new UILabel ( Toolkit . i18nText ( "Fine-Design_Replace_Search_Element" ) ) ;
rangeLabel = new UILabel ( Toolkit . i18nText ( "Fine-Design_Replace_Search_Range" ) ) ;
iconLabel = new UILabel ( CHANGE_ICON ) ;
resultLabel = new UILabel ( ) ;
String [ ] rangeItems = new String [ ] { Toolkit . i18nText ( "Fine-Design_Basic_Export_JS_Template_Current" ) } ;
@ -109,7 +122,7 @@ public class ITReplaceNorthPanel {
replaceButton = new UIButton ( Toolkit . i18nText ( "Fine-Design_Replace_Button" ) ) ;
searchButton = new UIButton ( Toolkit . i18nText ( "Fine-Design_Search_Button" ) ) ;
upPanel . setPreferredSize ( new Dimension ( LIMIT_WIDTH , HEIGHT ) ) ;
upPanel . setPreferredSize ( new Dimension ( limit_width , HEIGHT ) ) ;
scrollPane = new UIScrollPane ( upPanel , ScrollPaneConstants . VERTICAL_SCROLLBAR_NEVER , ScrollPaneConstants . HORIZONTAL_SCROLLBAR_AS_NEEDED ) ;
upPanel . add ( findLabel ) ;
upPanel . add ( rangeLabel ) ;
@ -121,6 +134,8 @@ public class ITReplaceNorthPanel {
upPanel . add ( matchRadioButton ) ;
upPanel . add ( replaceButton ) ;
upPanel . add ( searchButton ) ;
upPanel . add ( iconLabel ) ;
scrollPane . setBorder ( BorderFactory . createEmptyBorder ( ) ) ;
}
/ * *
@ -129,9 +144,8 @@ public class ITReplaceNorthPanel {
* @param width
* /
public void setLimitSize ( int width ) {
width = Math . max ( LIMIT_WIDTH , width ) ;
upPanel . setMaximumSize ( new Dimension ( width , 161 ) ) ;
upPanel . setPreferredSize ( new Dimension ( width , 161 ) ) ;
upPanel . setMaximumSize ( new Dimension ( limit_width , 161 ) ) ;
upPanel . setPreferredSize ( new Dimension ( limit_width , 161 ) ) ;
}
@ -144,21 +158,22 @@ public class ITReplaceNorthPanel {
* /
public void fitScreen ( int x , int y , int templateWidth ) {
templateWidth = Math . max ( templateWidth , LIMIT_WIDTH ) ;
setFindLabelBounds ( x , y , templateWidth ) ;
setRangeLabelBounds ( x , y , templateWidth ) ;
setResultLabelBounds ( x , y , templateWidth ) ;
templateWidth = Math . max ( ITReplaceMainDialog . MAIN_PANEL_WIDTH , templateWidth ) ;
templateWidth = templateWidth - ITReplaceWestPanel . LEFT_WIDTH ;
inputLength = ( templateWidth - GAP * 5 ) / 2 ;
setFindComboboxBounds ( x , y , templateWidth ) ;
setRangeComboboxBounds ( x , y , templateWidth ) ;
setFindInputComboboxBounds ( x , y , templateWidth ) ;
setReplaceInputComboboxBounds ( x , y , templateWidth ) ;
setUIRadioButtonBounds ( x , y , templateWidth ) ;
setReplaceButtonBounds ( x , y , templateWidth ) ;
setSearchButtonBounds ( x , y , templateWidth ) ;
setFindLabelBounds ( ) ;
setResultLabelBounds ( templateWidth ) ;
setFindComboboxBounds ( ) ;
setFindInputComboboxBounds ( ) ;
setReplaceInputComboboxBounds ( templateWidth ) ;
setRangeLabelBounds ( ) ;
setRangeComboboxBounds ( ) ;
setUIRadioButtonBounds ( ) ;
setReplaceButtonBounds ( ) ;
setSearchButtonBounds ( ) ;
setIconLabelBounds ( ) ;
}
@ -214,87 +229,94 @@ public class ITReplaceNorthPanel {
this . scrollPane = scrollPane ;
}
private void setIconLabelBounds ( ) {
iconX = inputLength + GAP ;
iconY = SECOND_Y ;
iconWidth = GAP ;
iconHeight = COMPONENT_HEIGHT ;
iconLabel . setBounds ( iconX , iconY , iconWidth , iconHeight ) ;
}
private void setSearchButtonBounds ( int x , int y , int templateWidth ) {
searchButtonHeight = 25 ;
searchButtonY = resultLabelY ;
private void setSearchButtonBounds ( ) {
searchButtonHeight = COMPONENT_HEIGHT ;
searchButtonY = FOURTH_ Y;
searchButtonX = replaceInputComboBoxX + replaceInputComboBoxWidth - BUTTON_WIDTH * 2 - BUTTON_GAP ;
searchButton . setBounds ( searchButtonX , searchButtonY , BUTTON_WIDTH , searchButtonHeight ) ;
}
private void setReplaceButtonBounds ( int x , int y , int templateWidth ) {
replaceButtonHeight = 25 ;
replaceButtonY = resultLabel Y;
private void setReplaceButtonBounds ( ) {
replaceButtonHeight = COMPONENT_HEIGHT ;
replaceButtonY = FOURTH_ Y;
replaceButtonX = replaceInputComboBoxX + replaceInputComboBoxWidth - BUTTON_WIDTH ;
replaceButton . setBounds ( replaceButtonX , replaceButtonY , BUTTON_WIDTH , replaceButtonHeight ) ;
}
private void setReplaceInputComboboxBounds ( int x , int y , int templateWidth ) {
replaceInputComboBoxX = x + templateWidth / 2 + templateWidth / 60 ;
replaceInputComboBoxY = y + 55 ;
replaceInputComboBoxWidth = templateWidth / 3 + templateWidth / 30 * 2 ;
replaceInputComboBoxHeight = 25 ;
private void setReplaceInputComboboxBounds ( int templateWidth ) {
replaceInputComboBoxX = templateWidth - inputLength - GAP * 2 ;
replaceInputComboBoxY = SECOND_Y ;
replaceInputComboBoxWidth = inputLength ;
replaceInputComboBoxHeight = COMPONENT_HEIGHT ;
replaceInputCombobox . setBounds ( replaceInputComboBoxX , replaceInputComboBoxY , replaceInputComboBoxWidth , replaceInputComboBoxHeight ) ;
}
private void setFindInputComboboxBounds ( int x , int y , int templateWidth ) {
findInputComboBoxX = x + templateWidth / 60 ;
findInputComboBoxY = y + 55 ;
findInputComboBoxWidth = templateWidth / 3 + templateWidth / 30 * 2 ;
findInputComboBoxHeight = 25 ;
private void setFindInputComboboxBounds ( ) {
findInputComboBoxX = FIRST_X ;
findInputComboBoxY = SECOND_Y ;
findInputComboBoxWidth = inputLength - GAP ;
findInputComboBoxHeight = COMPONENT_HEIGHT ;
findInputCombobox . setBounds ( findInputComboBoxX , findInputComboBoxY , findInputComboBoxWidth , findInputComboBoxHeight ) ;
}
private void setUIRadioButtonBounds ( int x , int y , int templateWidth ) {
matchX = x + templateWidth / 60 ;
matchY = y + 90 ;
private void setUIRadioButtonBounds ( ) {
matchX = FIRST_X ;
matchY = THIRD_Y ;
matchWidth = MATCH_WIDTH ;
matchHeight = 25 ;
matchHeight = COMPONENT_HEIGHT ;
matchRadioButton . setBounds ( matchX , matchY , matchWidth , matchHeight ) ;
}
private void setRangeComboboxBounds ( int x , int y , int templateWidth ) {
rangeComboBoxX = x + templateWidth / 2 + templateWidth / 15 ;
rangeComboBoxY = y + 20 ;
rangeComboBoxWidth = templateWidth / 3 + templateWidth / 60 ;
rangeComboBoxHeight = 25 ;
private void setRangeComboboxBounds ( ) {
rangeComboBoxX = rangeLabelX + rangeLabelWidth ;
rangeComboBoxY = FIRST_Y ;
rangeComboBoxWidth = inputLength - 3 * GAP ;
rangeComboBoxHeight = COMPONENT_HEIGHT ;
rangeCombobox . setBounds ( rangeComboBoxX , rangeComboBoxY , rangeComboBoxWidth , rangeComboBoxHeight ) ;
}
private void setFindComboboxBounds ( int x , int y , int templateWidth ) {
findComboBoxX = x + templateWidth / 30 * 2 ;
findComboBoxY = y + 20 ;
findComboBoxWidth = templateWidth / 3 + templateWidth / 60 ;
findComboBoxHeight = 25 ;
private void setFindComboboxBounds ( ) {
findComboBoxX = SECOND_X ;
findComboBoxY = FIRST_Y ;
findComboBoxWidth = inputLength - 4 * GAP ;
findComboBoxHeight = COMPONENT_HEIGHT ;
findCombobox . setBounds ( findComboBoxX , findComboBoxY , findComboBoxWidth , findComboBoxHeight ) ;
}
private void setResultLabelBounds ( int x , int y , int templateWidth ) {
resultLabelX = findLabel X;
resultLabelY = y + 125 ;
private void setResultLabelBounds ( int templateWidth ) {
resultLabelX = FIRST_ X;
resultLabelY = FOURTH_Y ;
resultLabelWidth = templateWidth ;
resultLabelHeight = 25 ;
resultLabelHeight = COMPONENT_HEIGHT ;
resultLabel . setBounds ( resultLabelX , resultLabelY , resultLabelWidth , resultLabelHeight ) ;
}
private void setRangeLabelBounds ( int x , int y , int templateWidth ) {
rangeLabelX = x + templateWidth / 2 + templateWidth / 60 ;
rangeLabelY = y + 20 ;
rangeLabelWidth = findLabelWidth ;
rangeLabelHeight = 25 ;
private void setRangeLabelBounds ( ) {
rangeLabelX = replaceInputComboBoxX ;
rangeLabelY = FIRST_Y ;
rangeLabelWidth = LABEL_WIDTH ;
rangeLabelHeight = COMPONENT_HEIGHT ;
rangeLabel . setBounds ( rangeLabelX , rangeLabelY , rangeLabelWidth , rangeLabelHeight ) ;
}
private void setFindLabelBounds ( int x , int y , int templateWidth ) {
findLabelX = x + templateWidth / 60 ;
findLabelY = y + 20 ;
findLabelWidth = templateWidth / 20 ;
findLabelHeight = 25 ;
private void setFindLabelBounds ( ) {
findLabelX = FIRST_X ;
findLabelY = FIRST_Y ;
findLabelWidth = LABEL_WIDTH ;
findLabelHeight = COMPONENT_HEIGHT ;
findLabel . setBounds ( findLabelX , findLabelY , findLabelWidth , findLabelHeight ) ;
}