Browse Source

Merge pull request #1036 in DESIGN/design from ~JINBOKAI/design:feature/10.0 to feature/10.0

* commit 'a7d3631dca4f644d8c69e73401412cb12b8aeaef':
  REPORT-20328 sonar
research/11.0
Jinbokai 5 years ago
parent
commit
079530d6a9
  1. 16
      designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIScrollBarUI.java
  2. 12
      designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java
  3. 18
      designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java
  4. 20
      designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/entity/FileEntityBuilder.java

16
designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIScrollBarUI.java

@ -1,5 +1,7 @@
package com.fr.design.gui.iscrollbar;
import com.fr.design.constants.UIConstants;
import com.fr.stable.StringUtils;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
@ -20,7 +22,6 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.BoundedRangeModel;
import javax.swing.InputMap;
import javax.swing.JComponent;
@ -38,8 +39,6 @@ import javax.swing.event.ChangeListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.ScrollBarUI;
import javax.swing.plaf.UIResource;
import com.fr.design.constants.UIConstants;
import sun.swing.DefaultLookup;
/**
@ -148,6 +147,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo
*
* @param c
*/
@Override
public void installUI(JComponent c) {
scrollbar = (JScrollBar) c;
thumbRect = new Rectangle(0, 0, 0, 0);
@ -163,6 +163,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo
*
* @param c
*/
@Override
public void uninstallUI(JComponent c) {
scrollbar = (JScrollBar) c;
uninstallListeners();
@ -357,6 +358,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo
/**
* 只画Thumb
*/
@Override
public void paint(Graphics g, JComponent c) {
Rectangle thumbBounds = getThumbBounds();
if (thumbBounds.intersects(g.getClipBounds())) {
@ -380,6 +382,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo
* @see #getMaximumSize
* @see #getMinimumSize
*/
@Override
public Dimension getPreferredSize(JComponent c) {
return (scrollbar.getOrientation() == JScrollBar.VERTICAL) ? new Dimension(scrollBarWidth, 48) : new Dimension(48, scrollBarWidth);
}
@ -390,6 +393,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo
* @see #getMinimumSize
* @see #getPreferredSize
*/
@Override
public Dimension getMaximumSize(JComponent c) {
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
}
@ -937,6 +941,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo
private transient int direction = +1;
@Override
public void mouseReleased(MouseEvent e) {
isPressing = false;
if (isDragging) {
@ -968,6 +973,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo
* one page. If there is no thumb then page up if the mouse is in the
* upper half of the track.
*/
@Override
public void mousePressed(MouseEvent e) {
boolean isMiddle = !isSupportsAbsolutePositioning() && SwingUtilities.isMiddleMouseButton(e);
if (SwingUtilities.isRightMouseButton(e) || isMiddle) {
@ -1313,7 +1319,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo
public void propertyChange(PropertyChangeEvent e) {
String propertyName = e.getPropertyName();
if ("model" == propertyName) {
if (StringUtils.equals("model", propertyName)) {
BoundedRangeModel oldModel = (BoundedRangeModel) e.getOldValue();
BoundedRangeModel newModel = (BoundedRangeModel) e.getNewValue();
oldModel.removeChangeListener(modelListener);
@ -1329,4 +1335,4 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo
}
}
}
}
}

12
designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java

@ -95,10 +95,6 @@ import com.fr.stable.module.Module;
import com.fr.stable.project.ProjectConstants;
import com.fr.web.controller.ViewRequestConstants;
import com.fr.workspace.WorkContext;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.FileOutputStream;
@ -106,6 +102,9 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JPanel;
/**
* JWorkBook used to edit WorkBook.
@ -1103,9 +1102,8 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
// 弹出输入参数
java.util.Map<String, Object> parameterMap = inputParameters(tpl);
try {
String fullPath = StableUtils.pathJoin(WorkContext.getCurrent().getPath(), newFile.getPath());
FileOutputStream fileOutputStream = new FileOutputStream(fullPath);
String fullPath = StableUtils.pathJoin(WorkContext.getCurrent().getPath(), newFile.getPath());
try (FileOutputStream fileOutputStream = new FileOutputStream(fullPath)) {
EmbeddedTableDataExporter exporter = new EmbeddedTableDataExporter();
exporter.export(fileOutputStream, tpl, parameterMap);
} catch (Exception e1) {

18
designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java

@ -2,14 +2,17 @@ package com.fr.design.mainframe.errorinfo;
import com.fr.base.FRContext;
import com.fr.general.IOUtils;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.stable.EncodeConstants;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.core.UUID;
import java.io.*;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.text.DateFormat;
import java.util.Date;
@ -124,13 +127,14 @@ public class ErrorInfo {
String content = jo.toString();
String fileName = UUID.randomUUID() + ErrorInfoUploader.SUFFIX;
File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), ErrorInfoUploader.FOLDER_NAME, fileName));
try {
FileOutputStream out = null;
try (InputStream in = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))) {
StableUtils.makesureFileExist(file);
FileOutputStream out = new FileOutputStream(file);
InputStream in = new ByteArrayInputStream(content.getBytes(EncodeConstants.ENCODING_UTF_8));
out = new FileOutputStream(file);
IOUtils.copyBinaryTo(in, out);
out.close();
} catch (IOException ignore) {
} finally {
IOUtils.close(out);
}
}
}

20
designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/entity/FileEntityBuilder.java

@ -19,7 +19,9 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.UUID;
import java.util.zip.ZipOutputStream;
/**
* @author alex sung
@ -52,13 +54,15 @@ public class FileEntityBuilder {
return null;
}
File zipFile = null;
ZipOutputStream zipOut = null;
try {
zipFile = new File(pathName + ".zip");
java.util.zip.ZipOutputStream zipOut = new java.util.zip.ZipOutputStream(new FileOutputStream(zipFile));
zipOut = new ZipOutputStream(new FileOutputStream(zipFile));
IOUtils.zip(zipOut, new File(pathName));
zipOut.close();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} finally {
IOUtils.close(zipOut);
}
return zipFile;
}
@ -67,18 +71,18 @@ public class FileEntityBuilder {
if (jsonArray.size() == 0) {
return;
}
try {
String content = jsonArray.toString();
FileOutputStream out = null;
String content = jsonArray.toString();
try (InputStream in = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))) {
String fileName = String.valueOf(UUID.randomUUID());
File file = new File(folderName + File.separator + fileName + ".json");
StableUtils.makesureFileExist(file);
FileOutputStream out = new FileOutputStream(file);
InputStream in = new ByteArrayInputStream(content.getBytes(EncodeConstants.ENCODING_UTF_8));
out = new FileOutputStream(file);
IOUtils.copyBinaryTo(in, out);
in.close();
out.close();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} finally {
IOUtils.close(out);
}
}

Loading…
Cancel
Save