forked from fanruan/design
Yvan
4 years ago
30 changed files with 457 additions and 88 deletions
@ -0,0 +1,50 @@
|
||||
package com.fr.design.update.factory; |
||||
|
||||
import com.fr.decision.update.data.UpdateConstants; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.stable.StableUtils; |
||||
|
||||
import java.io.File;; |
||||
|
||||
/** |
||||
* @author Bryant |
||||
* @version 10.0 |
||||
* Created by Bryant on 2020-09-29 |
||||
*/ |
||||
public class UpdateFileFactory { |
||||
|
||||
private UpdateFileFactory() { |
||||
} |
||||
|
||||
public static File[] getBackupVersions() { |
||||
File[] versions = null; |
||||
try { |
||||
File backupDir = new File(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR)); |
||||
StableUtils.mkdirs(backupDir); |
||||
versions = backupDir.listFiles(); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
return versions; |
||||
} |
||||
|
||||
public static boolean isBackupVersionsValid(String version) { |
||||
boolean designerValid = false; |
||||
boolean envValid = false; |
||||
try { |
||||
File designerLib = new File(StableUtils.pathJoin(version, UpdateConstants.DESIGNERBACKUPPATH)); |
||||
File[] jars = designerLib.listFiles(); |
||||
if (jars != null && jars.length > 0) { |
||||
designerValid = true; |
||||
} |
||||
File envLib = new File(StableUtils.pathJoin(version, UpdateConstants.BACKUPPATH)); |
||||
jars = envLib.listFiles(); |
||||
if (jars != null && jars.length > 0) { |
||||
envValid = true; |
||||
} |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
return designerValid && envValid; |
||||
} |
||||
} |
@ -0,0 +1,24 @@
|
||||
package com.fr.design.data.datapane; |
||||
|
||||
import org.junit.Test; |
||||
|
||||
import java.util.Map; |
||||
|
||||
import static org.junit.Assert.*; |
||||
|
||||
/** |
||||
* @author Yyming |
||||
* @version 10.0 |
||||
* Created by Yyming on 2020/9/29 |
||||
*/ |
||||
public class TableDataPaneListPaneTest { |
||||
|
||||
@Test |
||||
public void rename() { |
||||
TableDataPaneListPane listPane = new TableDataPaneListPane(); |
||||
listPane.rename("111", "222"); |
||||
listPane.rename("222", "333"); |
||||
Map<String, String> dsNameChangedMap = listPane.getDsNameChangedMap(); |
||||
assertEquals(1, dsNameChangedMap.size()); |
||||
} |
||||
} |
@ -0,0 +1,28 @@
|
||||
package com.fr.design.update.factory; |
||||
|
||||
import com.fr.decision.update.data.UpdateConstants; |
||||
import com.fr.stable.StableUtils; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
import java.io.File; |
||||
|
||||
public class UpdateFileFactoryTest { |
||||
|
||||
@Test |
||||
public void testGetBackupVersions() { |
||||
Assert.assertEquals(0, UpdateFileFactory.getBackupVersions().length); |
||||
File backupDir = new File(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR)); |
||||
StableUtils.deleteFile(backupDir); |
||||
} |
||||
|
||||
@Test |
||||
public void testIsBackupVersionsValid() { |
||||
File des = new File(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR, "test", UpdateConstants.BACKUPPATH, "test")); |
||||
File env = new File(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR, "test", UpdateConstants.DESIGNERBACKUPPATH, "test")); |
||||
StableUtils.mkdirs(des); |
||||
StableUtils.mkdirs(env); |
||||
Assert.assertTrue(UpdateFileFactory.isBackupVersionsValid(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR, "test"))); |
||||
StableUtils.deleteFile(new File(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR))); |
||||
} |
||||
} |
@ -1,58 +1,210 @@
|
||||
package com.fr.van.chart.designer.component.border; |
||||
|
||||
import com.fr.chart.base.AttrBorder; |
||||
import com.fr.chart.chartglyph.Marker; |
||||
import com.fr.chart.chartglyph.MarkerFactory; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.gui.ibutton.UIButtonGroup; |
||||
import com.fr.design.gui.icombobox.LineComboBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.ispinner.UISpinner; |
||||
import com.fr.design.gui.xcombox.MarkerComboBox; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.style.color.ColorSelectBox; |
||||
import com.fr.design.utils.gui.UIComponentUtils; |
||||
import com.fr.design.widget.FRWidgetFactory; |
||||
import com.fr.plugin.chart.base.AttrBorderWithShape; |
||||
import com.fr.plugin.chart.marker.type.MarkerType; |
||||
import com.fr.stable.Constants; |
||||
import com.fr.stable.CoreConstants; |
||||
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
public class VanChartBorderWithShapePane extends VanChartBorderWithRadiusPane { |
||||
public class VanChartBorderWithShapePane extends BasicPane { |
||||
private static final int RECTANGULAR_INDEX = 0; |
||||
private static final int DIALOG_INDEX = 1; |
||||
|
||||
private MarkerComboBox shapePane; |
||||
private static final int AUTO_COLOR = 0; |
||||
private static final int CUSTOM_COLOR = 1; |
||||
|
||||
protected void initComponents() { |
||||
shapePane = new MarkerComboBox(MarkerFactory.getLabelShapeMarkers()); |
||||
super.initComponents(); |
||||
private LineComboBox lineTypeBox; |
||||
private UIButtonGroup<Integer> lineColorButton; |
||||
private ColorSelectBox lineColorBox; |
||||
private MarkerComboBox borderShape; |
||||
private UISpinner borderRadius; |
||||
|
||||
private JPanel detailPane; |
||||
private JPanel colorBoxPane; |
||||
|
||||
public VanChartBorderWithShapePane() { |
||||
initComponents(); |
||||
createBorderPane(); |
||||
} |
||||
|
||||
private void initComponents() { |
||||
lineTypeBox = new LineComboBox(CoreConstants.STRIKE_LINE_STYLE_ARRAY_4_CHART); |
||||
lineColorButton = new UIButtonGroup<>(new String[]{ |
||||
Toolkit.i18nText("Fine-Design_Chart_Automatic"), |
||||
Toolkit.i18nText("Fine-Design_Chart_Custom") |
||||
}); |
||||
lineColorBox = new ColorSelectBox(100); |
||||
borderShape = new MarkerComboBox(MarkerFactory.getLabelShapeMarkers()); |
||||
borderRadius = new UISpinner(0, 1000, 1, 0); |
||||
} |
||||
|
||||
private void createBorderPane() { |
||||
this.setLayout(new BorderLayout()); |
||||
|
||||
detailPane = createDetailPane(); |
||||
|
||||
this.add(createLineTypePane(), BorderLayout.CENTER); |
||||
this.add(detailPane, BorderLayout.SOUTH); |
||||
|
||||
initLineTypeListener(); |
||||
initLineColorListener(); |
||||
initShapeListener(); |
||||
} |
||||
|
||||
private void initLineTypeListener() { |
||||
lineTypeBox.addActionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent e) { |
||||
checkDetailPane(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void checkDetailPane() { |
||||
detailPane.setVisible(lineTypeBox.getSelectedLineStyle() != Constants.LINE_NONE); |
||||
} |
||||
|
||||
protected Component[][] getUseComponent() { |
||||
return new Component[][]{ |
||||
private void initLineColorListener() { |
||||
lineColorButton.addActionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent e) { |
||||
checkColorPane(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void checkColorPane() { |
||||
colorBoxPane.setVisible(lineColorButton.getSelectedIndex() == CUSTOM_COLOR); |
||||
} |
||||
|
||||
private void initShapeListener() { |
||||
borderShape.addActionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent e) { |
||||
checkRadiusPane(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void checkRadiusPane() { |
||||
borderRadius.setEnabled(borderShape.getSelectedIndex() == RECTANGULAR_INDEX || borderShape.getSelectedIndex() == DIALOG_INDEX); |
||||
} |
||||
|
||||
private JPanel createLineTypePane() { |
||||
double p = TableLayout.PREFERRED; |
||||
double f = TableLayout.FILL; |
||||
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
||||
|
||||
double[] columnSize = {f, e}; |
||||
double[] rowSize = {p, p}; |
||||
|
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{null, null}, |
||||
new Component[]{FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Line_Style")), |
||||
UIComponentUtils.wrapWithBorderLayoutPane(currentLineCombo)}, |
||||
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), currentLineColorPane}, |
||||
UIComponentUtils.wrapWithBorderLayoutPane(lineTypeBox)}}; |
||||
|
||||
return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); |
||||
} |
||||
|
||||
private JPanel createDetailPane() { |
||||
double p = TableLayout.PREFERRED; |
||||
double f = TableLayout.FILL; |
||||
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
||||
|
||||
double[] columnSize = {f, e}; |
||||
double[] rowSize = {p, p, p}; |
||||
|
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{null, null}, |
||||
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Shape")), |
||||
UIComponentUtils.wrapWithBorderLayoutPane(shapePane)}, |
||||
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Radius")), getRadius()} |
||||
UIComponentUtils.wrapWithBorderLayoutPane(borderShape)}, |
||||
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Radius")), borderRadius} |
||||
}; |
||||
|
||||
JPanel center = createLineColorPane(); |
||||
JPanel south = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); |
||||
|
||||
JPanel panel = new JPanel(new BorderLayout()); |
||||
|
||||
panel.add(center, BorderLayout.CENTER); |
||||
panel.add(south, BorderLayout.SOUTH); |
||||
|
||||
return panel; |
||||
} |
||||
|
||||
protected double[] getRowSize() { |
||||
private JPanel createLineColorPane() { |
||||
double p = TableLayout.PREFERRED; |
||||
return new double[]{p, p, p, p, p}; |
||||
} |
||||
double f = TableLayout.FILL; |
||||
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
||||
|
||||
public void populate(AttrBorder border) { |
||||
super.populate(border); |
||||
double[] columnSize = {f, e}; |
||||
double[] rowSize = {p, p}; |
||||
|
||||
if (border instanceof AttrBorderWithShape) { |
||||
shapePane.setSelectedMarker((Marker.createMarker(((AttrBorderWithShape) border).getShape()))); |
||||
Component[][] center = new Component[][]{ |
||||
new Component[]{null, null}, |
||||
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), lineColorButton} |
||||
}; |
||||
|
||||
Component[][] south = new Component[][]{ |
||||
new Component[]{null, null}, |
||||
new Component[]{null, lineColorBox} |
||||
}; |
||||
|
||||
colorBoxPane = TableLayout4VanChartHelper.createGapTableLayoutPane(south, rowSize, columnSize); |
||||
|
||||
JPanel panel = new JPanel(new BorderLayout()); |
||||
|
||||
panel.add(TableLayout4VanChartHelper.createGapTableLayoutPane(center, rowSize, columnSize), BorderLayout.CENTER); |
||||
panel.add(colorBoxPane, BorderLayout.SOUTH); |
||||
|
||||
return panel; |
||||
} |
||||
|
||||
protected String title4PopupWindow() { |
||||
return null; |
||||
} |
||||
|
||||
public void populate(AttrBorderWithShape border) { |
||||
if (border == null) { |
||||
return; |
||||
} |
||||
|
||||
public void update(AttrBorder border) { |
||||
super.update(border); |
||||
lineTypeBox.setSelectedLineStyle(border.getBorderStyle()); |
||||
lineColorButton.setSelectedIndex(border.isAutoColor() ? AUTO_COLOR : CUSTOM_COLOR); |
||||
lineColorBox.setSelectObject(border.getBorderColor()); |
||||
borderShape.setSelectedMarker((Marker.createMarker(border.getShape()))); |
||||
borderRadius.setValue(border.getRoundRadius()); |
||||
|
||||
if (border instanceof AttrBorderWithShape) { |
||||
((AttrBorderWithShape) border).setShape(MarkerType.parse(shapePane.getSelectedMarkder().getMarkerType())); |
||||
checkDetailPane(); |
||||
checkColorPane(); |
||||
checkRadiusPane(); |
||||
} |
||||
|
||||
public void update(AttrBorderWithShape border) { |
||||
if (border == null) { |
||||
return; |
||||
} |
||||
|
||||
border.setBorderStyle(lineTypeBox.getSelectedLineStyle()); |
||||
border.setAutoColor(lineColorButton.getSelectedIndex() == AUTO_COLOR); |
||||
border.setBorderColor(lineColorBox.getSelectObject()); |
||||
border.setShape(MarkerType.parse(borderShape.getSelectedMarkder().getMarkerType())); |
||||
border.setRoundRadius((int) borderRadius.getValue()); |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue