白岳
5 years ago
29 changed files with 823 additions and 350 deletions
@ -0,0 +1,38 @@
|
||||
package com.fr.design.gui.ibutton; |
||||
|
||||
import com.fr.chart.base.ChartConstants; |
||||
import com.fr.design.constants.UIConstants; |
||||
import com.fr.design.style.color.ColorControlWindow; |
||||
import com.fr.design.style.color.ColorControlWindowWithAuto; |
||||
import com.fr.general.ComparatorUtils; |
||||
|
||||
import java.awt.Color; |
||||
|
||||
public class UIColorButtonWithAuto extends UIColorButton { |
||||
|
||||
protected void checkColorChange(Color oldColor, Color newColor) { |
||||
if (ComparatorUtils.equals(oldColor, ChartConstants.AUTO_FONT_COLOR) && !ComparatorUtils.equals(newColor, ChartConstants.AUTO_FONT_COLOR)) { |
||||
setIcon(UIConstants.FONT_ICON); |
||||
} |
||||
|
||||
if (!ComparatorUtils.equals(oldColor, ChartConstants.AUTO_FONT_COLOR) && ComparatorUtils.equals(newColor, ChartConstants.AUTO_FONT_COLOR)) { |
||||
setIcon(UIConstants.AUTO_FONT_ICON); |
||||
} |
||||
|
||||
super.checkColorChange(oldColor, newColor); |
||||
} |
||||
|
||||
protected ColorControlWindow getColorControlWindow() { |
||||
if (getPopupWin() == null) { |
||||
ColorControlWindowWithAuto colorControlWindowWithAuto = new ColorControlWindowWithAuto(UIColorButtonWithAuto.this) { |
||||
protected void colorChanged() { |
||||
UIColorButtonWithAuto.this.setColor(this.getColor()); |
||||
} |
||||
}; |
||||
|
||||
setPopupWin(colorControlWindowWithAuto); |
||||
} |
||||
|
||||
return getPopupWin(); |
||||
} |
||||
} |
@ -0,0 +1,116 @@
|
||||
package com.fr.design.style.color; |
||||
|
||||
import com.fr.chart.base.ChartConstants; |
||||
import com.fr.design.border.UIRoundedBorder; |
||||
import com.fr.design.constants.UIConstants; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.ipoppane.PopupHider; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
|
||||
import javax.swing.JPanel; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.event.ChangeListener; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
public abstract class ColorControlWindowWithAuto extends ColorControlWindow { |
||||
|
||||
private ColorSelectionPopupPaneWithAuto selectionPopupPaneWithAuto; |
||||
|
||||
public ColorControlWindowWithAuto(PopupHider popupHider) { |
||||
this(false, popupHider); |
||||
} |
||||
|
||||
public ColorControlWindowWithAuto(boolean isSupportTransparent, PopupHider popupHider) { |
||||
super(isSupportTransparent, popupHider); |
||||
} |
||||
|
||||
public Color getColor() { |
||||
if (selectionPopupPaneWithAuto == null) { |
||||
return null; |
||||
} |
||||
return selectionPopupPaneWithAuto.getColor(); |
||||
} |
||||
|
||||
protected void initSelectionPopupPane(boolean isSupportTransparent) { |
||||
selectionPopupPaneWithAuto = new ColorSelectionPopupPaneWithAuto(isSupportTransparent); |
||||
this.add(selectionPopupPaneWithAuto, BorderLayout.CENTER); |
||||
} |
||||
|
||||
class ColorSelectionPopupPaneWithAuto extends NewColorSelectPane { |
||||
private static final long serialVersionUID = 7822856562329146354L; |
||||
|
||||
public ColorSelectionPopupPaneWithAuto(boolean isSupportTransparent) { |
||||
super(isSupportTransparent); |
||||
|
||||
this.addChangeListener(new ChangeListener() { |
||||
|
||||
@Override |
||||
public void stateChanged(ChangeEvent e) { |
||||
colorChanged(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
protected void doTransparent() { |
||||
getPopupHider().hidePopupMenu(); |
||||
setColor(null); |
||||
} |
||||
|
||||
protected void doAuto() { |
||||
getPopupHider().hidePopupMenu(); |
||||
setColor(ChartConstants.AUTO_FONT_COLOR); |
||||
} |
||||
|
||||
public void customButtonPressed() { |
||||
getPopupHider().hidePopupMenu(); |
||||
super.customButtonPressed(); |
||||
} |
||||
|
||||
protected void initSelectButton(boolean isSupportTransparent) { |
||||
setSupportTransparent(isSupportTransparent); |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
this.setBorder(new UIRoundedBorder(UIConstants.TOOLBAR_BORDER_COLOR, 1, 5)); |
||||
|
||||
UIButton transparentButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_ChartF_Transparency")); |
||||
UIButton autoButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_ChartF_Auto")); |
||||
|
||||
transparentButton.addActionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent e) { |
||||
doTransparent(); |
||||
} |
||||
}); |
||||
|
||||
autoButton.addActionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent e) { |
||||
doAuto(); |
||||
} |
||||
}); |
||||
|
||||
if (isSupportTransparent) { |
||||
double p = TableLayout.PREFERRED; |
||||
double f = TableLayout.FILL; |
||||
double[] columnSize = {f, 0}; |
||||
double[] rowSize = {p, p}; |
||||
|
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{autoButton, null}, |
||||
new Component[]{transparentButton, null} |
||||
}; |
||||
|
||||
JPanel buttonGroup = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
||||
this.add(buttonGroup, BorderLayout.NORTH); |
||||
} else { |
||||
this.add(autoButton, BorderLayout.NORTH); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
After Width: | Height: | Size: 415 B |
@ -0,0 +1,58 @@
|
||||
package com.fr.design; |
||||
|
||||
import com.fr.design.env.DesignerWorkspaceInfo; |
||||
import com.fr.design.env.DesignerWorkspaceType; |
||||
import com.fr.design.write.submit.CheckServiceDialog; |
||||
import com.fr.workspace.connect.WorkspaceConnectionInfo; |
||||
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; |
||||
import org.easymock.EasyMock; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
import org.powermock.api.easymock.PowerMock; |
||||
import org.powermock.core.classloader.annotations.PrepareForTest; |
||||
import org.powermock.modules.junit4.PowerMockRunner; |
||||
|
||||
/** |
||||
* @author: Maksim |
||||
* @Date: Created in 2020/3/5 |
||||
* @Description: |
||||
*/ |
||||
@RunWith(PowerMockRunner.class) |
||||
@PrepareForTest({FunctionalHttpRequest.class,EnvChangeEntrance.class,CheckServiceDialog.class}) |
||||
public class EnvChangeEntranceTest { |
||||
|
||||
@Test |
||||
public void showServiceDialog() throws Exception { |
||||
try { |
||||
EnvChangeEntrance entrance = EnvChangeEntrance.getInstance(); |
||||
DesignerWorkspaceInfo selectedEnv = EasyMock.mock(DesignerWorkspaceInfo.class); |
||||
WorkspaceConnectionInfo connectionInfo = EasyMock.mock(WorkspaceConnectionInfo.class); |
||||
|
||||
String remoteBranch = "Build#persist-2020.02.15.01.01.12.12"; |
||||
EasyMock.expect(selectedEnv.getConnection()).andReturn(connectionInfo); |
||||
EasyMock.expect(selectedEnv.getType()).andReturn(DesignerWorkspaceType.Remote); |
||||
EasyMock.expect(selectedEnv.getRemindTime()).andReturn(null); |
||||
|
||||
FunctionalHttpRequest request = EasyMock.mock(FunctionalHttpRequest.class); |
||||
EasyMock.expect(request.getServiceList()).andReturn(null); |
||||
|
||||
PowerMock.expectNew(FunctionalHttpRequest.class, connectionInfo).andReturn(request).anyTimes(); |
||||
EasyMock.expect(request.getServerBranch()).andReturn(remoteBranch); |
||||
|
||||
CheckServiceDialog dialog = EasyMock.mock(CheckServiceDialog.class); |
||||
PowerMock.expectNew(CheckServiceDialog.class, EasyMock.anyObject(), EasyMock.anyObject(), EasyMock.anyObject(), EasyMock.anyObject()).andReturn(dialog); |
||||
|
||||
EasyMock.replay(request); |
||||
EasyMock.replay(selectedEnv); |
||||
EasyMock.replay(connectionInfo); |
||||
PowerMock.replayAll(); |
||||
|
||||
entrance.showServiceDialog(selectedEnv); |
||||
Assert.assertTrue(true); |
||||
}catch (Exception e){ |
||||
Assert.assertTrue(false); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,66 @@
|
||||
package com.fr.design.mainframe.chart.gui.style; |
||||
|
||||
import com.fr.chart.base.ChartConstants; |
||||
import com.fr.design.gui.ibutton.UIColorButton; |
||||
import com.fr.design.gui.ibutton.UIColorButtonWithAuto; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.FRFont; |
||||
import com.fr.general.GeneralUtils; |
||||
|
||||
public class ChartTextAttrPaneWithAuto extends ChartTextAttrPane { |
||||
|
||||
private static final String AUTO = Toolkit.i18nText("Fine-Design_Basic_ChartF_Auto"); |
||||
private boolean isFontSizeAuto = false; |
||||
private boolean isColorAuto = false; |
||||
public static String[] FONT_SIZES_WITH_AUTO = new String[FONT_END - FONT_START + 2]; |
||||
static { |
||||
FONT_SIZES_WITH_AUTO[0] = AUTO; |
||||
|
||||
for (int i = 1; i < FONT_SIZES_WITH_AUTO.length; i++) { |
||||
FONT_SIZES_WITH_AUTO[i] = FONT_START + i - 1 + ""; |
||||
} |
||||
} |
||||
|
||||
public ChartTextAttrPaneWithAuto() { |
||||
super(); |
||||
} |
||||
|
||||
public ChartTextAttrPaneWithAuto(boolean isFontSizeAuto, boolean isColorAuto) { |
||||
this.isFontSizeAuto = isFontSizeAuto; |
||||
this.isColorAuto = isColorAuto; |
||||
|
||||
initState(); |
||||
initComponents(); |
||||
} |
||||
|
||||
protected void initFontColorState() { |
||||
setFontColor(isColorAuto ? new UIColorButtonWithAuto() : new UIColorButton()); |
||||
} |
||||
|
||||
protected Object[] getFontSizeComboBoxModel() { |
||||
return isFontSizeAuto ? FONT_SIZES_WITH_AUTO : FONT_SIZES; |
||||
} |
||||
|
||||
protected float updateFontSize() { |
||||
if (isFontSizeAuto && ComparatorUtils.equals(getFontSizeComboBox().getSelectedItem(), AUTO)) { |
||||
return ChartConstants.AUTO_FONT_SIZE; |
||||
} |
||||
|
||||
return Float.parseFloat(GeneralUtils.objectToString(getFontSizeComboBox().getSelectedItem())); |
||||
} |
||||
|
||||
protected void populateFontSize(FRFont frFont) { |
||||
if (getFontSizeComboBox() != null && isFontSizeAuto) { |
||||
if (frFont.getSize() == ChartConstants.AUTO_FONT_SIZE) { |
||||
getFontSizeComboBox().setSelectedItem(AUTO); |
||||
} else { |
||||
getFontSizeComboBox().setSelectedItem(frFont.getSize() + ""); |
||||
} |
||||
} |
||||
|
||||
if (getFontSizeComboBox() != null && !isFontSizeAuto) { |
||||
getFontSizeComboBox().setSelectedItem(frFont.getSize()); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue