Browse Source

Merge pull request #1649 in BA/design from ~JU/design:release/9.0 to master

* commit 'f0b43228114f8cbc27c8833ad38faf56881fba8c':
  REPORT-6932 水印插件安装后需要重启生效 添加插件监听
stable20180208_164904
superman 7 years ago
parent
commit
7d0a5e2072
  1. 29
      designer_base/src/com/fr/design/gui/style/BorderPane.java
  2. 62
      designer_base/src/com/fr/design/style/background/BackgroundFactory.java

29
designer_base/src/com/fr/design/gui/style/BorderPane.java

@ -11,6 +11,7 @@ import com.fr.design.constants.LayoutConstants;
import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.fun.BackgroundQuickUIProvider;
import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.ilable.UILabel;
@ -20,7 +21,12 @@ import com.fr.design.mainframe.backgroundpane.ColorBackgroundQuickPane;
import com.fr.design.style.color.NewColorSelectBox;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.general.Inter;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.manage.PluginFilter;
import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
import com.fr.stable.Constants;
import com.fr.stable.CoreConstants;
@ -64,6 +70,7 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse
}
protected void initComponents() {
initButtonsWithIcon();
this.setLayout(new BorderLayout(0, 0));
JPanel externalPane = new JPanel(new GridLayout(0, 4));
@ -96,7 +103,7 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse
borderPanel = new UIExpandablePane(Inter.getLocText("FR-Designer_Border"), 280, 24, panel);
this.add(borderPanel, BorderLayout.NORTH);
backgroundPane = new BackgroundPane();
initBackgroundPane();
backgroundPanel = new UIExpandablePane(Inter.getLocText("FR-Designer_Background"), 280, 24, backgroundPane);
this.add(backgroundPanel, BorderLayout.CENTER);
initAllNames();
@ -104,6 +111,26 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse
innerToggleButton.addChangeListener(innerToggleButtonChangeListener);
}
private void initBackgroundPane() {
//初始化背景pane并监听插件
backgroundPane = new BackgroundPane();
GeneralContext.listenPluginRunningChanged(new PluginEventListener() {
@Override
public void on(PluginEvent event) {
backgroundPane = new BackgroundPane();
}
}, new PluginFilter() {
@Override
public boolean accept(PluginContext context) {
return context.contain(BackgroundQuickUIProvider.MARK_STRING);
}
});
}
ChangeListener outerToggleButtonChangeListener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {

62
designer_base/src/com/fr/design/style/background/BackgroundFactory.java

@ -1,13 +1,29 @@
package com.fr.design.style.background;
import com.fr.base.background.*;
import com.fr.base.background.ColorBackground;
import com.fr.base.background.GradientBackground;
import com.fr.base.background.ImageBackground;
import com.fr.base.background.PatternBackground;
import com.fr.base.background.TextureBackground;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.BackgroundUIProvider;
import com.fr.design.style.background.gradient.GradientBackgroundPane;
import com.fr.design.style.background.impl.*;
import com.fr.design.style.background.impl.ColorBackgroundPane;
import com.fr.design.style.background.impl.ImageBackgroundPane;
import com.fr.design.style.background.impl.ImageBackgroundPane4Browser;
import com.fr.design.style.background.impl.ImageButtonBackgroundPane;
import com.fr.design.style.background.impl.NullBackgroundPane;
import com.fr.design.style.background.impl.PatternBackgroundPane;
import com.fr.design.style.background.impl.TextureBackgroundPane;
import com.fr.general.Background;
import com.fr.general.GeneralContext;
import com.fr.general.Inter;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.manage.PluginFilter;
import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
import com.fr.plugin.observer.PluginEventType;
import java.util.LinkedHashMap;
import java.util.Map;
@ -29,9 +45,51 @@ public class BackgroundFactory {
registerBrowserImageBackground(browser);
registerExtra(map);
registerExtra(browser);
listenPlugin();
registerButtonBackground(button);
}
private static void listenPlugin() {
PluginFilter filter = new PluginFilter() {
@Override
public boolean accept(PluginContext context) {
return context.contain(BackgroundUIProvider.MARK_STRING);
}
};
GeneralContext.listenPlugin(PluginEventType.BeforeStop, new PluginEventListener() {
@Override
public void on(PluginEvent event) {
Set<BackgroundUIProvider> set = event.getContext().getRuntime().get(BackgroundUIProvider.MARK_STRING);
for (BackgroundUIProvider provider : set) {
map.remove(provider.targetClass());
browser.remove(provider.targetClass());
}
}
}, filter);
GeneralContext.listenPlugin(PluginEventType.AfterRun, new PluginEventListener() {
@Override
public void on(PluginEvent event) {
Set<BackgroundUIProvider> set = event.getContext().getRuntime().get(BackgroundUIProvider.MARK_STRING);
Class<? extends Background> clazz;
BackgroundUIWrapper wrapper;
for (BackgroundUIProvider provider : set) {
clazz = provider.targetClass();
wrapper = BackgroundUIWrapper.create().setType(provider.targetUIClass()).setTitle(provider.targetTitle());
map.put(clazz, wrapper);
browser.put(clazz, wrapper);
}
}
});
}
private static void registerUniversal(Map<Class<? extends Background>, BackgroundUIWrapper> map) {
map.put(null, BackgroundUIWrapper.create()
.setType(NullBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Null")));

Loading…
Cancel
Save