Browse Source

IOUtils添加资源加载接口,可访问到IOUtils的地方都用IOUtils加载资源,访问不到的话再直接用ResourceLoader

master
juhaoyu 8 years ago
parent
commit
7ea04c49a5
  1. 4
      designer/src/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java
  2. 4
      designer/src/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java
  3. 10
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  4. 4
      designer/src/com/fr/design/mainframe/bbs/BBSConstants.java
  5. 10
      designer_base/src/com/fr/design/extra/QQLoginWebPane.java
  6. 4
      designer_base/src/com/fr/design/gui/UILookAndFeel.java
  7. 6
      designer_chart/src/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java

4
designer/src/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java

@ -4,7 +4,7 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.stable.resource.ResourceLoader; import com.fr.general.IOUtils;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -34,7 +34,7 @@ public class ContentCellRender implements ListCellRenderer<Object> {
AlphaCellModel model = (AlphaCellModel) value; AlphaCellModel model = (AlphaCellModel) value;
name.setText(model.getName()); name.setText(model.getName());
String iconUrl = "/com/fr/design/mainframe/alphafine/images/alphafine" + model.getType().getTypeValue() + ".png"; String iconUrl = "/com/fr/design/mainframe/alphafine/images/alphafine" + model.getType().getTypeValue() + ".png";
name.setIcon(new ImageIcon(ResourceLoader.getResource(iconUrl, getClass()))); name.setIcon(new ImageIcon(IOUtils.getResource(iconUrl, getClass())));
name.setFont(AlphaFineConstants.MEDIUM_FONT); name.setFont(AlphaFineConstants.MEDIUM_FONT);
name.setForeground(AlphaFineConstants.BLACK); name.setForeground(AlphaFineConstants.BLACK);
name.setVerticalTextPosition(SwingConstants.CENTER); name.setVerticalTextPosition(SwingConstants.CENTER);

4
designer/src/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java

@ -3,7 +3,7 @@ package com.fr.design.mainframe.alphafine.cell.render;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.stable.resource.ResourceLoader; import com.fr.general.IOUtils;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -37,7 +37,7 @@ public class TitleCellRender implements ListCellRenderer<Object> {
panel.add(this.more, BorderLayout.EAST); panel.add(this.more, BorderLayout.EAST);
} }
if (moreModel.isLoading()) { if (moreModel.isLoading()) {
ImageIcon imageIcon = new ImageIcon(ResourceLoader.getResource("/com/fr/design/mainframe/alphafine/images/loading.gif", getClass())); ImageIcon imageIcon = new ImageIcon(IOUtils.getResource("/com/fr/design/mainframe/alphafine/images/loading.gif", getClass()));
//设置cell的加载动画 //设置cell的加载动画
imageIcon.setImageObserver(list); imageIcon.setImageObserver(list);

10
designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java

@ -26,6 +26,7 @@ import com.fr.form.main.Form;
import com.fr.form.main.FormIO; import com.fr.form.main.FormIO;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.general.IOUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.io.TemplateWorkBookIO; import com.fr.io.TemplateWorkBookIO;
@ -36,7 +37,6 @@ import com.fr.main.impl.WorkBook;
import com.fr.stable.CodeUtils; import com.fr.stable.CodeUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.stable.resource.ResourceLoader;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.swing.*; import javax.swing.*;
@ -83,7 +83,7 @@ public class AlphaFineDialog extends UIDialog {
searchTextField.setBorderPainted(false); searchTextField.setBorderPainted(false);
searchTextField.initKeyListener(this); searchTextField.initKeyListener(this);
JPanel topPane = new JPanel(new BorderLayout()); JPanel topPane = new JPanel(new BorderLayout());
UILabel iconLabel = new UILabel(new ImageIcon(ResourceLoader.getResource("/com/fr/design/mainframe/alphafine/images/bigsearch.png", getClass()))); UILabel iconLabel = new UILabel(new ImageIcon(IOUtils.getResource("/com/fr/design/mainframe/alphafine/images/bigsearch.png", getClass())));
iconLabel.setPreferredSize(AlphaFineConstants.ICON_LABEL_SIZE); iconLabel.setPreferredSize(AlphaFineConstants.ICON_LABEL_SIZE);
iconLabel.setOpaque(true); iconLabel.setOpaque(true);
iconLabel.setBackground(Color.white); iconLabel.setBackground(Color.white);
@ -99,7 +99,7 @@ public class AlphaFineDialog extends UIDialog {
}; };
closeButton.setContentAreaFilled(false); closeButton.setContentAreaFilled(false);
closeButton.setPreferredSize(AlphaFineConstants.CLOSE_BUTTON_SIZE); closeButton.setPreferredSize(AlphaFineConstants.CLOSE_BUTTON_SIZE);
closeButton.setIcon(new ImageIcon(ResourceLoader.getResource("/com/fr/design/mainframe/alphafine/images/alphafine_close.png", getClass()))); closeButton.setIcon(new ImageIcon(IOUtils.getResource("/com/fr/design/mainframe/alphafine/images/alphafine_close.png", getClass())));
closeButton.set4ToolbarButton(); closeButton.set4ToolbarButton();
closeButton.addActionListener(new ActionListener() { closeButton.addActionListener(new ActionListener() {
@Override @Override
@ -372,7 +372,7 @@ public class AlphaFineDialog extends UIDialog {
bufferedImage = ImageIO.read(new URL(((PluginModel) selectedValue).getImageUrl())); bufferedImage = ImageIO.read(new URL(((PluginModel) selectedValue).getImageUrl()));
} catch (IOException e) { } catch (IOException e) {
try { try {
bufferedImage = ImageIO.read(ResourceLoader.getResource("/com/fr/design/mainframe/alphafine/images/default_product.png", getClass())); bufferedImage = ImageIO.read(IOUtils.getResource("/com/fr/design/mainframe/alphafine/images/default_product.png", getClass()));
} catch (IOException e1) { } catch (IOException e1) {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
} }
@ -418,7 +418,7 @@ public class AlphaFineDialog extends UIDialog {
private void showDefaultPreviewPane() { private void showDefaultPreviewPane() {
rightSearchResultPane.removeAll(); rightSearchResultPane.removeAll();
UILabel label = new UILabel(new ImageIcon(ResourceLoader.getResource("/com/fr/design/mainframe/alphafine/images/opening.gif", getClass()))); UILabel label = new UILabel(new ImageIcon(IOUtils.getResource("/com/fr/design/mainframe/alphafine/images/opening.gif", getClass())));
label.setBorder(BorderFactory.createEmptyBorder(120,0,0,0)); label.setBorder(BorderFactory.createEmptyBorder(120,0,0,0));
rightSearchResultPane.add(label, BorderLayout.CENTER); rightSearchResultPane.add(label, BorderLayout.CENTER);
validate(); validate();

4
designer/src/com/fr/design/mainframe/bbs/BBSConstants.java

@ -3,8 +3,8 @@
*/ */
package com.fr.design.mainframe.bbs; package com.fr.design.mainframe.bbs;
import com.fr.general.IOUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.resource.ResourceLoader;
import java.util.Properties; import java.util.Properties;
@ -44,7 +44,7 @@ public class BBSConstants {
if (PROP == null) { if (PROP == null) {
PROP = new Properties(); PROP = new Properties();
try { try {
PROP.load(ResourceLoader.getResourceAsStream("/com/fr/design/mainframe/bbs/bbs.properties", BBSConstants.class)); PROP.load(IOUtils.getResourceAsStream("/com/fr/design/mainframe/bbs/bbs.properties", BBSConstants.class));
} catch (Exception e) { } catch (Exception e) {
} }
} }

10
designer_base/src/com/fr/design/extra/QQLoginWebPane.java

@ -1,11 +1,7 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.general.ComparatorUtils; import com.fr.general.*;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.general.SiteCenter;
import com.fr.stable.resource.ResourceLoader;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.beans.property.BooleanProperty; import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleBooleanProperty;
@ -75,7 +71,7 @@ public class QQLoginWebPane extends JFXPanel {
try { try {
primaryStage.initStyle(StageStyle.TRANSPARENT); primaryStage.initStyle(StageStyle.TRANSPARENT);
primaryStage.setScene(new Scene(layout)); primaryStage.setScene(new Scene(layout));
webView.getScene().getStylesheets().add(ResourceLoader.getResource("modal-dialog.css", getClass()).toExternalForm()); webView.getScene().getStylesheets().add(IOUtils.getResource("modal-dialog.css", getClass()).toExternalForm());
primaryStage.initStyle(StageStyle.UTILITY); primaryStage.initStyle(StageStyle.UTILITY);
primaryStage.setScene(new Scene(new Group(), DEFAULT_PRIMARYSTAGE_WIDTH, DEFAULT_PRIMARYSTAGE_HEIGHT)); primaryStage.setScene(new Scene(new Group(), DEFAULT_PRIMARYSTAGE_WIDTH, DEFAULT_PRIMARYSTAGE_HEIGHT));
primaryStage.setX(0); primaryStage.setX(0);
@ -194,7 +190,7 @@ public class QQLoginWebPane extends JFXPanel {
); );
configDrag(dialog); configDrag(dialog);
// style and show the dialog. // style and show the dialog.
dialog.getScene().getStylesheets().add(ResourceLoader.getResource("modal-dialog.css", getClass()).toExternalForm()); dialog.getScene().getStylesheets().add(IOUtils.getResource("modal-dialog.css", getClass()).toExternalForm());
dialog.setOnCloseRequest(new EventHandler<WindowEvent>() { dialog.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override @Override
public void handle(WindowEvent event) { public void handle(WindowEvent event) {

4
designer_base/src/com/fr/design/gui/UILookAndFeel.java

@ -27,7 +27,7 @@ import com.fr.design.gui.itoolbar.UIToolBarSeparatorUI;
import com.fr.design.gui.itooltip.UIToolTipBorder; import com.fr.design.gui.itooltip.UIToolTipBorder;
import com.fr.design.gui.itree.UITreeUI; import com.fr.design.gui.itree.UITreeUI;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.stable.resource.ResourceLoader; import com.fr.general.IOUtils;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border; import javax.swing.border.Border;
@ -188,7 +188,7 @@ public class UILookAndFeel extends MetalLookAndFeel {
if (url == null) { if (url == null) {
// Another try // Another try
url = ResourceLoader.getResource( url = IOUtils.getResource(
"com/fr/design/images/lookandfeel/" + fileName, UILookAndFeel.class); "com/fr/design/images/lookandfeel/" + fileName, UILookAndFeel.class);
if (url == null) { if (url == null) {

6
designer_chart/src/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java

@ -3,7 +3,7 @@ package com.fr.design.mainframe.chart.gui.type;
import com.fr.design.chart.series.PlotStyle.ChartSelectDemoPane; import com.fr.design.chart.series.PlotStyle.ChartSelectDemoPane;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.stable.resource.ResourceLoader; import com.fr.general.IOUtils;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -15,7 +15,7 @@ public class ChartImagePane extends ChartSelectDemoPane {
public boolean isDoubleClicked = false; public boolean isDoubleClicked = false;
public ChartImagePane(String iconPath, String tipName) {// 建立太复杂? 耗费内存.. public ChartImagePane(String iconPath, String tipName) {// 建立太复杂? 耗费内存..
UILabel image = new UILabel(new ImageIcon(ResourceLoader.getResource(iconPath, getClass()))); UILabel image = new UILabel(new ImageIcon(IOUtils.getResource(iconPath, getClass())));
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
this.add(image, BorderLayout.CENTER); this.add(image, BorderLayout.CENTER);
addMouseListener(this); addMouseListener(this);
@ -30,7 +30,7 @@ public class ChartImagePane extends ChartSelectDemoPane {
private void constructImagePane(String fullIconPath, String tipName, boolean isDrawRightLine){ private void constructImagePane(String fullIconPath, String tipName, boolean isDrawRightLine){
UILabel image = new UILabel(new ImageIcon(ResourceLoader.getResource(fullIconPath, getClass()))); UILabel image = new UILabel(new ImageIcon(IOUtils.getResource(fullIconPath, getClass())));
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
this.add(image, BorderLayout.CENTER); this.add(image, BorderLayout.CENTER);
addMouseListener(this); addMouseListener(this);

Loading…
Cancel
Save