kerry
4 years ago
31 changed files with 512 additions and 409 deletions
@ -0,0 +1,51 @@
|
||||
package com.fr.design.mainframe.predefined.ui.detail.background; |
||||
|
||||
import com.fr.design.event.UIObserverListener; |
||||
import com.fr.design.mainframe.backgroundpane.BackgroundQuickPane; |
||||
import com.fr.general.Background; |
||||
|
||||
import javax.swing.event.ChangeListener; |
||||
|
||||
/** |
||||
* Created by kerry on 2020-09-14 |
||||
*/ |
||||
public abstract class AbstractBackgroundDetailPane<T extends Background> extends BackgroundQuickPane { |
||||
@Override |
||||
public boolean accept(Background background) { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(Background background) { |
||||
this.populate((T) background); |
||||
} |
||||
|
||||
@Override |
||||
public Background updateBean() { |
||||
return this.update(); |
||||
} |
||||
|
||||
@Override |
||||
public String title4PopupWindow() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void reset() { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void registerChangeListener(UIObserverListener listener) { |
||||
|
||||
} |
||||
|
||||
public abstract void populate(T background); |
||||
|
||||
public abstract T update(); |
||||
|
||||
public void addChangeListener(ChangeListener changeListener) { |
||||
|
||||
} |
||||
|
||||
} |
@ -1,99 +0,0 @@
|
||||
package com.fr.design.mainframe.predefined.ui.detail.background; |
||||
|
||||
import com.fr.general.Background; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import java.awt.Dimension; |
||||
|
||||
/** |
||||
* Created by kerry on 2020-08-31 |
||||
*/ |
||||
public enum BackgroundType { |
||||
EMPTY_BACKGROUND("NullBackground", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Background_Is_Null")) { |
||||
@Override |
||||
public Dimension getDisplayDimension() { |
||||
return new Dimension(0, 0); |
||||
} |
||||
}, |
||||
COLOR_BACKGROUND("ColorBackground", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Color")) { |
||||
@Override |
||||
public Dimension getDisplayDimension() { |
||||
return new Dimension(242, 187); |
||||
} |
||||
}, |
||||
TEXTURE_BACKGROUND("TextureBackground", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture")) { |
||||
@Override |
||||
public Dimension getDisplayDimension() { |
||||
return new Dimension(242, 155); |
||||
} |
||||
}, |
||||
PATTERN_BACKGROUND("PatternBackground", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Pattern")) { |
||||
@Override |
||||
public Dimension getDisplayDimension() { |
||||
return new Dimension(242, 266); |
||||
} |
||||
}, |
||||
IMAGE_BACKGROUND("ImageBackground", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Image")) { |
||||
@Override |
||||
public Dimension getDisplayDimension() { |
||||
return new Dimension(242, 160); |
||||
} |
||||
}, |
||||
GRADIENT_BACKGROUND("GradientBackground", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Gradient_Color")) { |
||||
@Override |
||||
public Dimension getDisplayDimension() { |
||||
return new Dimension(242, 155); |
||||
} |
||||
}; |
||||
|
||||
private String backgroundType; |
||||
|
||||
private String displayName; |
||||
|
||||
|
||||
BackgroundType(String backgroundType, String displayName) { |
||||
this.backgroundType = backgroundType; |
||||
this.displayName = displayName; |
||||
} |
||||
|
||||
|
||||
public String getDisplayName() { |
||||
return displayName; |
||||
} |
||||
|
||||
public abstract Dimension getDisplayDimension(); |
||||
|
||||
public static String[] allTypes() { |
||||
BackgroundType[] backgroundTypes = values(); |
||||
String[] backgrounds = new String[backgroundTypes.length]; |
||||
for (int i = 0; i < backgroundTypes.length; i++) { |
||||
backgrounds[i] = backgroundTypes[i].getDisplayName(); |
||||
} |
||||
return backgrounds; |
||||
} |
||||
|
||||
public static BackgroundType parse(Background background) { |
||||
if (background == null) { |
||||
return EMPTY_BACKGROUND; |
||||
} |
||||
for (BackgroundType type : values()) { |
||||
if (ComparatorUtils.equals(background.getBackgroundType(), type.backgroundType)) { |
||||
return type; |
||||
} |
||||
} |
||||
return EMPTY_BACKGROUND; |
||||
} |
||||
|
||||
public static BackgroundType parse(String displayName) { |
||||
if (StringUtils.isEmpty(displayName)) { |
||||
return EMPTY_BACKGROUND; |
||||
} |
||||
for (BackgroundType type : values()) { |
||||
if (ComparatorUtils.equals(displayName, type.displayName)) { |
||||
return type; |
||||
} |
||||
} |
||||
return EMPTY_BACKGROUND; |
||||
} |
||||
} |
@ -0,0 +1,48 @@
|
||||
package com.fr.design.mainframe.predefined.ui.detail.background; |
||||
|
||||
import com.fr.design.ExtraDesignClassManager; |
||||
import com.fr.design.event.UIObserverListener; |
||||
import com.fr.design.fun.BackgroundQuickUIProvider; |
||||
import com.fr.design.mainframe.backgroundpane.BackgroundQuickPane; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* Created by kerry on 2020-09-14 |
||||
*/ |
||||
public class FormBackgroundSettingPane extends BackgroundSettingPane { |
||||
|
||||
public FormBackgroundSettingPane() { |
||||
super(); |
||||
} |
||||
|
||||
@Override |
||||
protected BackgroundQuickPane[] supportKindsOfBackgroundUI() { |
||||
ColorDetailPane colorDetailPane = new ColorDetailPane(); |
||||
ImageDetailPane imageDetailPane = createImageSelectPane(); |
||||
GradientDetailPane gradientPane = new GradientDetailPane(); |
||||
//hugh:表单支持背景接口
|
||||
List<BackgroundQuickPane> kinds = new ArrayList<BackgroundQuickPane>(); |
||||
|
||||
kinds.add(new EmptyBackgroundPane()); |
||||
kinds.add(colorDetailPane); |
||||
kinds.add(imageDetailPane); |
||||
kinds.add(gradientPane); |
||||
|
||||
Set<BackgroundQuickUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(BackgroundQuickUIProvider.MARK_STRING); |
||||
for (BackgroundQuickUIProvider provider : providers) { |
||||
BackgroundQuickPane newTypePane = provider.appearanceForBackground(); |
||||
newTypePane.registerChangeListener(new UIObserverListener() { |
||||
@Override |
||||
public void doChange() { |
||||
fireChangeListener(); |
||||
} |
||||
}); |
||||
kinds.add(newTypePane); |
||||
} |
||||
|
||||
return kinds.toArray(new BackgroundQuickPane[kinds.size()]); |
||||
} |
||||
} |
Loading…
Reference in new issue