@ -1,33 +1,10 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
||||||
<classpath> |
<classpath> |
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.6u35"/> |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
||||||
<classpathentry kind="src" path="src"/> |
<classpathentry kind="src" path="src"/> |
||||||
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/lib"/> |
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/lib"/> |
||||||
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/base"/> |
<classpathentry kind="lib" path="D:/Program Files/Git/finereport/lib/report/fr-core-8.0.jar"/> |
||||||
<classpathentry combineaccessrules="false" kind="src" path="/base-stable"/> |
<classpathentry kind="lib" path="D:/Program Files/Git/finereport/lib/report/fr-third-8.0.jar"/> |
||||||
<classpathentry combineaccessrules="false" kind="src" path="/base-basic"/> |
<classpathentry kind="lib" path="D:/Program Files/Git/finereport/lib/jetty/org.mortbay.jetty.jar"/> |
||||||
<classpathentry kind="lib" path="/lib/jetty/activation.jar"/> |
|
||||||
<classpathentry kind="lib" path="/lib/jetty/commons-el.jar"/> |
|
||||||
<classpathentry kind="lib" path="/lib/jetty/commons-logging.jar"/> |
|
||||||
<classpathentry kind="lib" path="/lib/jetty/jasper-compiler.jar"/> |
|
||||||
<classpathentry kind="lib" path="/lib/jetty/jasper-runtime.jar"/> |
|
||||||
<classpathentry kind="lib" path="/lib/jetty/javax.servlet.jar"/> |
|
||||||
<classpathentry kind="lib" path="/lib/jetty/jaxrpc.jar"/> |
|
||||||
<classpathentry kind="lib" path="/lib/jetty/mail.jar"/> |
|
||||||
<classpathentry kind="lib" path="/lib/jetty/mx4j-remote.jar"/> |
|
||||||
<classpathentry kind="lib" path="/lib/jetty/mx4j-tools.jar"/> |
|
||||||
<classpathentry kind="lib" path="/lib/jetty/mx4j.jar"/> |
|
||||||
<classpathentry kind="lib" path="/lib/jetty/org.mortbay.jetty.jar"/> |
|
||||||
<classpathentry kind="lib" path="/lib/jetty/org.mortbay.jmx.jar"/> |
|
||||||
<classpathentry kind="lib" path="/lib/jetty/saaj.jar"/> |
|
||||||
<classpathentry kind="lib" path="/lib/jetty/xercesImpl.jar"/> |
|
||||||
<classpathentry kind="lib" path="/lib/jetty/xml-apis.jar"/> |
|
||||||
<classpathentry kind="lib" path="/lib/jetty/xmlParserAPIs.jar"/> |
|
||||||
<classpathentry kind="lib" path="/lib/3rd.jar"/> |
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/base-calculate"/> |
|
||||||
<classpathentry kind="lib" path="/lib/junit.jar"/> |
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/base-data"/> |
|
||||||
<classpathentry kind="lib" path="/lib/olap4j-1.1.0.jar"/> |
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/base-file"/> |
|
||||||
<classpathentry kind="output" path="bin"/> |
<classpathentry kind="output" path="bin"/> |
||||||
</classpath> |
</classpath> |
||||||
|
@ -0,0 +1,74 @@ |
|||||||
|
package com.fr.design.actions.community; |
||||||
|
|
||||||
|
import java.awt.Desktop; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.io.IOException; |
||||||
|
import java.net.URI; |
||||||
|
import java.net.URISyntaxException; |
||||||
|
|
||||||
|
import javax.swing.JOptionPane; |
||||||
|
import javax.swing.KeyStroke; |
||||||
|
|
||||||
|
import com.fr.base.BaseUtils; |
||||||
|
import com.fr.base.FRContext; |
||||||
|
import com.fr.design.actions.UpdateAction; |
||||||
|
import com.fr.design.menu.MenuKeySet; |
||||||
|
import com.fr.general.Inter; |
||||||
|
import com.fr.general.SiteCenter; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
public class BBSAction extends UpdateAction |
||||||
|
{ |
||||||
|
|
||||||
|
|
||||||
|
public BBSAction() |
||||||
|
{ |
||||||
|
this.setMenuKeySet(BBS); |
||||||
|
this.setName(getMenuKeySet().getMenuName()); |
||||||
|
this.setMnemonic(getMenuKeySet().getMnemonic()); |
||||||
|
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/bbs.png")); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 动作 |
||||||
|
* @param e 事件 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent arg0) |
||||||
|
{ |
||||||
|
String url = SiteCenter.getInstance().acquireUrlByKind("bbs"); |
||||||
|
if (StringUtils.isEmpty(url)) { |
||||||
|
FRContext.getLogger().info("The URL is empty!"); |
||||||
|
return; |
||||||
|
} |
||||||
|
try { |
||||||
|
Desktop.getDesktop().browse(new URI(url)); |
||||||
|
} catch (IOException exp) { |
||||||
|
JOptionPane.showMessageDialog(null, Inter.getLocText("Set_default_browser")); |
||||||
|
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); |
||||||
|
} catch (URISyntaxException exp) { |
||||||
|
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); |
||||||
|
} catch (Exception exp) { |
||||||
|
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); |
||||||
|
FRContext.getLogger().error("Can not open the browser for URL: " + url); |
||||||
|
} |
||||||
|
} |
||||||
|
public static final MenuKeySet BBS = new MenuKeySet() { |
||||||
|
@Override |
||||||
|
public char getMnemonic() { |
||||||
|
return 'B'; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getMenuName() { |
||||||
|
return Inter.getLocText("FR-Designer_COMMUNITY_BBS"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public KeyStroke getKeyStroke() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,72 @@ |
|||||||
|
package com.fr.design.actions.community; |
||||||
|
|
||||||
|
import java.awt.Desktop; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.io.IOException; |
||||||
|
import java.net.URI; |
||||||
|
import java.net.URISyntaxException; |
||||||
|
|
||||||
|
import javax.swing.JOptionPane; |
||||||
|
import javax.swing.KeyStroke; |
||||||
|
|
||||||
|
import com.fr.base.BaseUtils; |
||||||
|
import com.fr.base.FRContext; |
||||||
|
import com.fr.design.actions.UpdateAction; |
||||||
|
import com.fr.design.menu.MenuKeySet; |
||||||
|
import com.fr.general.Inter; |
||||||
|
import com.fr.general.SiteCenter; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
public class BugAction extends UpdateAction |
||||||
|
{ |
||||||
|
|
||||||
|
public BugAction() |
||||||
|
{ this.setMenuKeySet(BUG); |
||||||
|
this.setName(getMenuKeySet().getMenuName()); |
||||||
|
this.setMnemonic(getMenuKeySet().getMnemonic()); |
||||||
|
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/bug.png")); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent arg0) |
||||||
|
{ |
||||||
|
String url = SiteCenter.getInstance().acquireUrlByKind("bbs.bugs"); |
||||||
|
if (StringUtils.isEmpty(url)) { |
||||||
|
FRContext.getLogger().info("The URL is empty!"); |
||||||
|
return; |
||||||
|
} |
||||||
|
try { |
||||||
|
Desktop.getDesktop().browse(new URI(url)); |
||||||
|
} catch (IOException exp) { |
||||||
|
JOptionPane.showMessageDialog(null, Inter.getLocText("Set_default_browser")); |
||||||
|
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); |
||||||
|
} catch (URISyntaxException exp) { |
||||||
|
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); |
||||||
|
} catch (Exception exp) { |
||||||
|
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); |
||||||
|
FRContext.getLogger().error("Can not open the browser for URL: " + url); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
public static final MenuKeySet BUG = new MenuKeySet() { |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getMenuName() { |
||||||
|
return Inter.getLocText("FR-Designer_COMMUNITY_BUG"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public KeyStroke getKeyStroke() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public char getMnemonic() |
||||||
|
{ |
||||||
|
|
||||||
|
return 'U'; |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,70 @@ |
|||||||
|
package com.fr.design.actions.community; |
||||||
|
|
||||||
|
import java.awt.Desktop; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.io.IOException; |
||||||
|
import java.net.URI; |
||||||
|
import java.net.URISyntaxException; |
||||||
|
|
||||||
|
import javax.swing.JOptionPane; |
||||||
|
import javax.swing.KeyStroke; |
||||||
|
|
||||||
|
import com.fr.base.BaseUtils; |
||||||
|
import com.fr.base.FRContext; |
||||||
|
import com.fr.design.actions.UpdateAction; |
||||||
|
import com.fr.design.menu.MenuKeySet; |
||||||
|
import com.fr.general.Inter; |
||||||
|
import com.fr.general.SiteCenter; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
public class NeedAction extends UpdateAction |
||||||
|
{ |
||||||
|
|
||||||
|
public NeedAction() |
||||||
|
{ |
||||||
|
this.setMenuKeySet(NEED); |
||||||
|
this.setName(getMenuKeySet().getMenuName()); |
||||||
|
this.setMnemonic(getMenuKeySet().getMnemonic()); |
||||||
|
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/need.png")); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent arg0) |
||||||
|
{ |
||||||
|
String url = SiteCenter.getInstance().acquireUrlByKind("bbs.needs"); |
||||||
|
if (StringUtils.isEmpty(url)) { |
||||||
|
FRContext.getLogger().info("The URL is empty!"); |
||||||
|
return; |
||||||
|
} |
||||||
|
try { |
||||||
|
Desktop.getDesktop().browse(new URI(url)); |
||||||
|
} catch (IOException exp) { |
||||||
|
JOptionPane.showMessageDialog(null, Inter.getLocText("Set_default_browser")); |
||||||
|
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); |
||||||
|
} catch (URISyntaxException exp) { |
||||||
|
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); |
||||||
|
} catch (Exception exp) { |
||||||
|
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); |
||||||
|
FRContext.getLogger().error("Can not open the browser for URL: " + url); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
public static final MenuKeySet NEED = new MenuKeySet() { |
||||||
|
@Override |
||||||
|
public char getMnemonic() { |
||||||
|
return 'N'; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getMenuName() { |
||||||
|
return Inter.getLocText("FR-Designer_COMMUNITY_NEED"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public KeyStroke getKeyStroke() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,69 @@ |
|||||||
|
package com.fr.design.actions.community; |
||||||
|
|
||||||
|
import java.awt.Desktop; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.io.IOException; |
||||||
|
import java.net.URI; |
||||||
|
import java.net.URISyntaxException; |
||||||
|
|
||||||
|
import javax.swing.JOptionPane; |
||||||
|
import javax.swing.KeyStroke; |
||||||
|
|
||||||
|
import com.fr.base.BaseUtils; |
||||||
|
import com.fr.base.FRContext; |
||||||
|
import com.fr.design.actions.UpdateAction; |
||||||
|
import com.fr.design.menu.MenuKeySet; |
||||||
|
import com.fr.general.Inter; |
||||||
|
import com.fr.general.SiteCenter; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
public class QuestionAction extends UpdateAction |
||||||
|
{ |
||||||
|
|
||||||
|
public QuestionAction() |
||||||
|
{ this.setMenuKeySet(QUESTIONS); |
||||||
|
this.setName(getMenuKeySet().getMenuName()); |
||||||
|
this.setMnemonic(getMenuKeySet().getMnemonic()); |
||||||
|
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/questions.png")); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent arg0) |
||||||
|
{ |
||||||
|
String url = SiteCenter.getInstance().acquireUrlByKind("bbs.questions"); |
||||||
|
if (StringUtils.isEmpty(url)) { |
||||||
|
FRContext.getLogger().info("The URL is empty!"); |
||||||
|
return; |
||||||
|
} |
||||||
|
try { |
||||||
|
Desktop.getDesktop().browse(new URI(url)); |
||||||
|
} catch (IOException exp) { |
||||||
|
JOptionPane.showMessageDialog(null, Inter.getLocText("Set_default_browser")); |
||||||
|
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); |
||||||
|
} catch (URISyntaxException exp) { |
||||||
|
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); |
||||||
|
} catch (Exception exp) { |
||||||
|
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); |
||||||
|
FRContext.getLogger().error("Can not open the browser for URL: " + url); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
public static final MenuKeySet QUESTIONS = new MenuKeySet() { |
||||||
|
@Override |
||||||
|
public char getMnemonic() { |
||||||
|
return 'Q'; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getMenuName() { |
||||||
|
return Inter.getLocText("FR-Designer_COMMUNITY_QUESTIONS"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public KeyStroke getKeyStroke() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,70 @@ |
|||||||
|
package com.fr.design.actions.community; |
||||||
|
|
||||||
|
import java.awt.Desktop; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.io.IOException; |
||||||
|
import java.net.URI; |
||||||
|
import java.net.URISyntaxException; |
||||||
|
|
||||||
|
import javax.swing.JOptionPane; |
||||||
|
import javax.swing.KeyStroke; |
||||||
|
|
||||||
|
import com.fr.base.BaseUtils; |
||||||
|
import com.fr.base.FRContext; |
||||||
|
import com.fr.design.actions.UpdateAction; |
||||||
|
import com.fr.design.menu.MenuKeySet; |
||||||
|
import com.fr.general.Inter; |
||||||
|
import com.fr.general.SiteCenter; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
public class SignAction extends UpdateAction |
||||||
|
{ |
||||||
|
|
||||||
|
public SignAction() |
||||||
|
{ |
||||||
|
this.setMenuKeySet(SIGN); |
||||||
|
this.setName(getMenuKeySet().getMenuName()); |
||||||
|
this.setMnemonic(getMenuKeySet().getMnemonic()); |
||||||
|
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/signature.png")); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent arg0) |
||||||
|
{ |
||||||
|
String url = SiteCenter.getInstance().acquireUrlByKind("bbs.aut"); |
||||||
|
if (StringUtils.isEmpty(url)) { |
||||||
|
FRContext.getLogger().info("The URL is empty!"); |
||||||
|
return; |
||||||
|
} |
||||||
|
try { |
||||||
|
Desktop.getDesktop().browse(new URI(url)); |
||||||
|
} catch (IOException exp) { |
||||||
|
JOptionPane.showMessageDialog(null, Inter.getLocText("Set_default_browser")); |
||||||
|
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); |
||||||
|
} catch (URISyntaxException exp) { |
||||||
|
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); |
||||||
|
} catch (Exception exp) { |
||||||
|
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); |
||||||
|
FRContext.getLogger().error("Can not open the browser for URL: " + url); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
public static final MenuKeySet SIGN = new MenuKeySet() { |
||||||
|
@Override |
||||||
|
public char getMnemonic() { |
||||||
|
return 'S'; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getMenuName() { |
||||||
|
return Inter.getLocText("FR-Designer_COMMUNITY_SIGN"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public KeyStroke getKeyStroke() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,70 @@ |
|||||||
|
package com.fr.design.actions.community; |
||||||
|
|
||||||
|
import java.awt.Desktop; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.io.IOException; |
||||||
|
import java.net.URI; |
||||||
|
import java.net.URISyntaxException; |
||||||
|
|
||||||
|
import javax.swing.JOptionPane; |
||||||
|
import javax.swing.KeyStroke; |
||||||
|
|
||||||
|
import com.fr.base.BaseUtils; |
||||||
|
import com.fr.base.FRContext; |
||||||
|
import com.fr.design.actions.UpdateAction; |
||||||
|
import com.fr.design.menu.MenuKeySet; |
||||||
|
import com.fr.general.Inter; |
||||||
|
import com.fr.general.SiteCenter; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
public class UpAction extends UpdateAction |
||||||
|
{ |
||||||
|
|
||||||
|
public UpAction() |
||||||
|
{ |
||||||
|
this.setMenuKeySet(UPDATE); |
||||||
|
this.setName(getMenuKeySet().getMenuName()); |
||||||
|
this.setMnemonic(getMenuKeySet().getMnemonic()); |
||||||
|
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/update.png")); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent arg0) |
||||||
|
{ |
||||||
|
String url = SiteCenter.getInstance().acquireUrlByKind("bbs.update"); |
||||||
|
if (StringUtils.isEmpty(url)) { |
||||||
|
FRContext.getLogger().info("The URL is empty!"); |
||||||
|
return; |
||||||
|
} |
||||||
|
try { |
||||||
|
Desktop.getDesktop().browse(new URI(url)); |
||||||
|
} catch (IOException exp) { |
||||||
|
JOptionPane.showMessageDialog(null, Inter.getLocText("Set_default_browser")); |
||||||
|
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); |
||||||
|
} catch (URISyntaxException exp) { |
||||||
|
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); |
||||||
|
} catch (Exception exp) { |
||||||
|
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); |
||||||
|
FRContext.getLogger().error("Can not open the browser for URL: " + url); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
public static final MenuKeySet UPDATE = new MenuKeySet() { |
||||||
|
@Override |
||||||
|
public char getMnemonic() { |
||||||
|
return 'U'; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getMenuName() { |
||||||
|
return Inter.getLocText("FR-Designer_COMMUNITY_UPDATE"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public KeyStroke getKeyStroke() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,70 @@ |
|||||||
|
package com.fr.design.actions.community; |
||||||
|
|
||||||
|
import java.awt.Desktop; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.io.IOException; |
||||||
|
import java.net.URI; |
||||||
|
import java.net.URISyntaxException; |
||||||
|
|
||||||
|
import javax.swing.JOptionPane; |
||||||
|
import javax.swing.KeyStroke; |
||||||
|
|
||||||
|
import com.fr.base.BaseUtils; |
||||||
|
import com.fr.base.FRContext; |
||||||
|
import com.fr.design.actions.UpdateAction; |
||||||
|
import com.fr.design.menu.MenuKeySet; |
||||||
|
import com.fr.general.Inter; |
||||||
|
import com.fr.general.SiteCenter; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
public class VideoAction extends UpdateAction |
||||||
|
{ |
||||||
|
|
||||||
|
public VideoAction() |
||||||
|
{ |
||||||
|
this.setMenuKeySet(VIDEO); |
||||||
|
this.setName(getMenuKeySet().getMenuName()); |
||||||
|
this.setMnemonic(getMenuKeySet().getMnemonic()); |
||||||
|
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/video.png")); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent arg0) |
||||||
|
{ |
||||||
|
String url = SiteCenter.getInstance().acquireUrlByKind("bbs.video"); |
||||||
|
if (StringUtils.isEmpty(url)) { |
||||||
|
FRContext.getLogger().info("The URL is empty!"); |
||||||
|
return; |
||||||
|
} |
||||||
|
try { |
||||||
|
Desktop.getDesktop().browse(new URI(url)); |
||||||
|
} catch (IOException exp) { |
||||||
|
JOptionPane.showMessageDialog(null, Inter.getLocText("Set_default_browser")); |
||||||
|
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); |
||||||
|
} catch (URISyntaxException exp) { |
||||||
|
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); |
||||||
|
} catch (Exception exp) { |
||||||
|
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); |
||||||
|
FRContext.getLogger().error("Can not open the browser for URL: " + url); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
public static final MenuKeySet VIDEO = new MenuKeySet() { |
||||||
|
@Override |
||||||
|
public char getMnemonic() { |
||||||
|
return 'V'; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getMenuName() { |
||||||
|
return Inter.getLocText("FR-Designer_COMMUNITY_VIDEO"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public KeyStroke getKeyStroke() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,62 @@ |
|||||||
|
package com.fr.design.data.datapane; |
||||||
|
|
||||||
|
import com.fr.data.TableDataSource; |
||||||
|
import com.fr.file.DatasourceManagerProvider; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* Coder: zack |
||||||
|
* Date: 2016/5/18 |
||||||
|
* Time: 10:13 |
||||||
|
*/ |
||||||
|
public interface TableDataPaneController { |
||||||
|
/** |
||||||
|
* 获取数据集名字变更集合 |
||||||
|
* |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
Map<String, String> getDsNameChangedMap(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 数据集重命名 |
||||||
|
* |
||||||
|
* @param oldName |
||||||
|
* @param newName |
||||||
|
*/ |
||||||
|
void rename(String oldName, String newName); |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否合法 |
||||||
|
* @throws Exception |
||||||
|
*/ |
||||||
|
void checkValid() throws Exception; |
||||||
|
|
||||||
|
/** |
||||||
|
* 名字是否允许 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
boolean isNamePermitted(); |
||||||
|
|
||||||
|
void populate(DatasourceManagerProvider datasourceManagerProvider); |
||||||
|
|
||||||
|
void update(DatasourceManagerProvider datasourceManagerProvider); |
||||||
|
|
||||||
|
void populate(TableDataSource datasourceManagerProvider); |
||||||
|
|
||||||
|
void update(TableDataSource datasourceManagerProvider); |
||||||
|
|
||||||
|
/** |
||||||
|
* 设置选中项 |
||||||
|
* @param index |
||||||
|
*/ |
||||||
|
void setSelectedIndex(int index); |
||||||
|
|
||||||
|
/** |
||||||
|
* 返回当前数据集面板 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
JPanel getPanel(); |
||||||
|
|
||||||
|
} |
@ -1,261 +1,276 @@ |
|||||||
package com.fr.design.data.datapane; |
package com.fr.design.data.datapane; |
||||||
|
|
||||||
import com.fr.base.TableData; |
import com.fr.base.TableData; |
||||||
import com.fr.data.TableDataSource; |
import com.fr.data.TableDataSource; |
||||||
import com.fr.data.impl.storeproc.StoreProcedure; |
import com.fr.data.impl.storeproc.StoreProcedure; |
||||||
import com.fr.design.data.DesignTableDataManager; |
import com.fr.design.data.DesignTableDataManager; |
||||||
import com.fr.design.gui.controlpane.JControlPane; |
import com.fr.design.gui.controlpane.JListControlPane; |
||||||
import com.fr.design.gui.controlpane.NameableCreator; |
import com.fr.design.gui.controlpane.NameableCreator; |
||||||
import com.fr.design.gui.ilist.ListModelElement; |
import com.fr.design.gui.ilist.ListModelElement; |
||||||
import com.fr.file.DatasourceManagerProvider; |
import com.fr.file.DatasourceManagerProvider; |
||||||
import com.fr.general.ComparatorUtils; |
import com.fr.general.ComparatorUtils; |
||||||
import com.fr.general.Inter; |
import com.fr.general.Inter; |
||||||
import com.fr.general.NameObject; |
import com.fr.general.NameObject; |
||||||
import com.fr.stable.Nameable; |
import com.fr.stable.Nameable; |
||||||
import com.fr.stable.StringUtils; |
import com.fr.stable.StringUtils; |
||||||
import com.fr.stable.core.PropertyChangeAdapter; |
import com.fr.stable.core.PropertyChangeAdapter; |
||||||
|
|
||||||
import javax.swing.*; |
import javax.swing.*; |
||||||
import java.util.*; |
import java.util.*; |
||||||
|
|
||||||
/** |
/** |
||||||
* TableDataList Pane. |
* TableDataList Pane. |
||||||
*/ |
*/ |
||||||
public class TableDataListPane extends JControlPane { |
public class TableDataPaneListPane extends JListControlPane implements TableDataPaneController { |
||||||
private Map<String, String> dsNameChangedMap = new HashMap<String, String>(); |
private boolean isNamePermitted = true; |
||||||
private boolean isNamePermitted = true; |
private Map<String, String> dsNameChangedMap = new HashMap<String, String>(); |
||||||
|
|
||||||
public TableDataListPane() { |
public TableDataPaneListPane() { |
||||||
super(); |
super(); |
||||||
dsNameChangedMap.clear(); |
dsNameChangedMap.clear(); |
||||||
this.addEditingListner(new PropertyChangeAdapter() { |
this.addEditingListner(new PropertyChangeAdapter() { |
||||||
@Override |
@Override |
||||||
public void propertyChange() { |
public void propertyChange() { |
||||||
isNamePermitted = true; |
isNamePermitted = true; |
||||||
TableDataSource source = DesignTableDataManager.getEditingTableDataSource(); |
TableDataSource source = DesignTableDataManager.getEditingTableDataSource(); |
||||||
String[] allDSNames = DesignTableDataManager.getAllDSNames(source); |
String[] allDSNames = DesignTableDataManager.getAllDSNames(source); |
||||||
String[] allListNames = nameableList.getAllNames(); |
String[] allListNames = nameableList.getAllNames(); |
||||||
allListNames[nameableList.getSelectedIndex()] = StringUtils.EMPTY; |
allListNames[nameableList.getSelectedIndex()] = StringUtils.EMPTY; |
||||||
String tempName = getEditingName(); |
String tempName = getEditingName(); |
||||||
Object editingType = getEditingType(); |
Object editingType = getEditingType(); |
||||||
if (StringUtils.isEmpty(tempName)) { |
if (StringUtils.isEmpty(tempName)) { |
||||||
String[] warning = new String[]{"NOT_NULL_Des", "Please_Rename"}; |
String[] warning = new String[]{"NOT_NULL_Des", "Please_Rename"}; |
||||||
String[] sign = new String[]{",", "!"}; |
String[] sign = new String[]{",", "!"}; |
||||||
isNamePermitted = false; |
isNamePermitted = false; |
||||||
nameableList.stopEditing(); |
nameableList.stopEditing(); |
||||||
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataListPane.this), Inter.getLocText(warning, sign)); |
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this), Inter.getLocText(warning, sign)); |
||||||
setWarnigText(editingIndex); |
setWarnigText(editingIndex); |
||||||
return; |
return; |
||||||
} |
} |
||||||
|
|
||||||
if (!ComparatorUtils.equals(tempName, selectedName) |
if (!ComparatorUtils.equals(tempName, selectedName) |
||||||
&& isNameRepeted(new List[]{Arrays.asList(allDSNames), Arrays.asList(allListNames)}, tempName)) { |
&& isNameRepeted(new List[]{Arrays.asList(allDSNames), Arrays.asList(allListNames)}, tempName)) { |
||||||
String[] waning = new String[]{"already_exists", "TableData", "Please_Rename"}; |
String[] waning = new String[]{"already_exists", "TableData", "Please_Rename"}; |
||||||
String[] sign = new String[]{"", tempName + ",", "!"}; |
String[] sign = new String[]{"", tempName + ",", "!"}; |
||||||
isNamePermitted = false; |
isNamePermitted = false; |
||||||
nameableList.stopEditing(); |
nameableList.stopEditing(); |
||||||
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataListPane.this), Inter.getLocText(waning, sign)); |
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this), Inter.getLocText(waning, sign)); |
||||||
setWarnigText(editingIndex); |
setWarnigText(editingIndex); |
||||||
} else if (editingType instanceof StoreProcedure && isIncludeUnderline(tempName)) { |
} else if (editingType instanceof StoreProcedure && isIncludeUnderline(tempName)) { |
||||||
String[] datasource_underline = new String[]{"Datasource-Stored_Procedure", "Name", "can_not_include_underline"}; |
String[] datasource_underline = new String[]{"Datasource-Stored_Procedure", "Name", "can_not_include_underline"}; |
||||||
String[] sign = new String[]{"", "", "!"}; |
String[] sign = new String[]{"", "", "!"}; |
||||||
isNamePermitted = false; |
isNamePermitted = false; |
||||||
nameableList.stopEditing(); |
nameableList.stopEditing(); |
||||||
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataListPane.this), Inter.getLocText(datasource_underline, sign)); |
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this), Inter.getLocText(datasource_underline, sign)); |
||||||
setWarnigText(editingIndex); |
setWarnigText(editingIndex); |
||||||
} |
} |
||||||
if (nameableList.getSelectedValue() instanceof ListModelElement) { |
if (nameableList.getSelectedValue() instanceof ListModelElement) { |
||||||
Nameable selected = ((ListModelElement) nameableList.getSelectedValue()).wrapper; |
Nameable selected = ((ListModelElement) nameableList.getSelectedValue()).wrapper; |
||||||
if (!ComparatorUtils.equals(tempName, selected.getName())) { |
if (!ComparatorUtils.equals(tempName, selected.getName())) { |
||||||
rename(selected.getName(), tempName); |
rename(selected.getName(), tempName); |
||||||
|
|
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
||||||
}); |
}); |
||||||
} |
} |
||||||
|
|
||||||
protected void rename(String oldName, String newName) { |
@Override |
||||||
dsNameChangedMap.put(oldName, newName); |
public void rename(String oldName, String newName) { |
||||||
} |
dsNameChangedMap.put(oldName, newName); |
||||||
|
} |
||||||
/** |
|
||||||
* 名字是否允许 |
/** |
||||||
* |
* 名字是否允许 |
||||||
* @return 是/否 |
* |
||||||
*/ |
* @return 是/否 |
||||||
public boolean isNamePermitted() { |
*/ |
||||||
return isNamePermitted; |
@Override |
||||||
} |
public boolean isNamePermitted() { |
||||||
|
return isNamePermitted; |
||||||
|
} |
||||||
/** |
|
||||||
* 检查按钮可用状态 Check button enabled. |
|
||||||
*/ |
/** |
||||||
public void checkButtonEnabled() { |
* 检查按钮可用状态 Check button enabled. |
||||||
super.checkButtonEnabled(); |
*/ |
||||||
isNamePermitted = !isContainsRename(); |
@Override |
||||||
} |
public void checkButtonEnabled() { |
||||||
|
super.checkButtonEnabled(); |
||||||
private boolean isIncludeUnderline(String name) { |
isNamePermitted = !isContainsRename(); |
||||||
return ComparatorUtils.equals(name.indexOf(StoreProcedure.SPLIT), -1) ? false : true; |
} |
||||||
} |
|
||||||
|
private boolean isIncludeUnderline(String name) { |
||||||
/** |
return ComparatorUtils.equals(name.indexOf(StoreProcedure.SPLIT), -1) ? false : true; |
||||||
* 创建服务器数据集所需要的NameableCreator数组 |
} |
||||||
* |
|
||||||
* @return 数组 |
/** |
||||||
*/ |
* 创建服务器数据集所需要的NameableCreator数组 |
||||||
public NameableCreator[] createNameableCreators() { |
* |
||||||
return TableDataCreatorProducer.getInstance().createServerTableDataCreator(); |
* @return 数组 |
||||||
} |
*/ |
||||||
|
@Override |
||||||
|
public NameableCreator[] createNameableCreators() { |
||||||
// 只能保证当前模板不重名了
|
return TableDataCreatorProducer.getInstance().createServerTableDataCreator(); |
||||||
|
} |
||||||
/** |
|
||||||
* 新建不重名的面板 |
|
||||||
* |
// 只能保证当前模板不重名了
|
||||||
* @param prefix 前缀字符 |
|
||||||
* @return 生成的名字 |
/** |
||||||
*/ |
* 新建不重名的面板 |
||||||
@Override |
* |
||||||
public String createUnrepeatedName(String prefix) { |
* @param prefix 前缀字符 |
||||||
TableDataSource source = DesignTableDataManager.getEditingTableDataSource(); |
* @return 生成的名字 |
||||||
if (source == null) { |
*/ |
||||||
return super.createUnrepeatedName(prefix); |
@Override |
||||||
} |
public String createUnrepeatedName(String prefix) { |
||||||
String[] allDsNames = DesignTableDataManager.getAllDSNames(source); |
TableDataSource source = DesignTableDataManager.getEditingTableDataSource(); |
||||||
DefaultListModel model = this.getModel(); |
if (source == null) { |
||||||
Nameable[] all = new Nameable[model.getSize()]; |
return super.createUnrepeatedName(prefix); |
||||||
for (int i = 0; i < model.size(); i++) { |
} |
||||||
all[i] = ((ListModelElement) model.get(i)).wrapper; |
String[] allDsNames = DesignTableDataManager.getAllDSNames(source); |
||||||
} |
DefaultListModel model = this.getModel(); |
||||||
// richer:生成的名字从1开始. kunsnat: 添加属性从0开始.
|
Nameable[] all = new Nameable[model.getSize()]; |
||||||
int count = all.length + 1; |
for (int i = 0; i < model.size(); i++) { |
||||||
while (true) { |
all[i] = ((ListModelElement) model.get(i)).wrapper; |
||||||
String name_test = prefix + count; |
} |
||||||
boolean repeated = false; |
// richer:生成的名字从1开始. kunsnat: 添加属性从0开始.
|
||||||
for (int i = 0, len = model.size(); i < len; i++) { |
int count = all.length + 1; |
||||||
Nameable nameable = all[i]; |
while (true) { |
||||||
if (ComparatorUtils.equals(nameable.getName(), name_test)) { |
String name_test = prefix + count; |
||||||
repeated = true; |
boolean repeated = false; |
||||||
break; |
for (int i = 0, len = model.size(); i < len; i++) { |
||||||
} |
Nameable nameable = all[i]; |
||||||
} |
if (ComparatorUtils.equals(nameable.getName(), name_test)) { |
||||||
for (String dsname : allDsNames) { |
repeated = true; |
||||||
if (ComparatorUtils.equals(dsname, name_test)) { |
break; |
||||||
repeated = true; |
} |
||||||
break; |
} |
||||||
} |
for (String dsname : allDsNames) { |
||||||
} |
if (ComparatorUtils.equals(dsname, name_test)) { |
||||||
|
repeated = true; |
||||||
if (!repeated) { |
break; |
||||||
return name_test; |
} |
||||||
} |
} |
||||||
|
|
||||||
count++; |
if (!repeated) { |
||||||
} |
return name_test; |
||||||
} |
} |
||||||
|
|
||||||
@Override |
count++; |
||||||
protected String title4PopupWindow() { |
} |
||||||
return "TableData"; |
} |
||||||
} |
|
||||||
|
@Override |
||||||
/** |
protected String title4PopupWindow() { |
||||||
* Populate. |
return "TableData"; |
||||||
*/ |
} |
||||||
public void populate(TableDataSource tds) { |
|
||||||
List<NameObject> nameObjectList = new ArrayList<NameObject>(); |
/** |
||||||
|
* Populate. |
||||||
Iterator tableDataNameIterator = tds.getTableDataNameIterator(); |
*/ |
||||||
while (tableDataNameIterator.hasNext()) { |
@Override |
||||||
String tableDataName = (String) tableDataNameIterator.next(); |
public void populate(TableDataSource tds) { |
||||||
TableData tableData = tds.getTableData(tableDataName); |
List<NameObject> nameObjectList = new ArrayList<NameObject>(); |
||||||
|
|
||||||
if (tableData != null) { |
Iterator tableDataNameIterator = tds.getTableDataNameIterator(); |
||||||
nameObjectList.add(new NameObject(tableDataName, tableData)); |
while (tableDataNameIterator.hasNext()) { |
||||||
} |
String tableDataName = (String) tableDataNameIterator.next(); |
||||||
} |
TableData tableData = tds.getTableData(tableDataName); |
||||||
|
|
||||||
populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); |
if (tableData != null) { |
||||||
} |
nameObjectList.add(new NameObject(tableDataName, tableData)); |
||||||
|
} |
||||||
/** |
} |
||||||
* Populate. |
|
||||||
*/ |
populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); |
||||||
public void populate(DatasourceManagerProvider datasourceManager) { |
} |
||||||
Iterator<String> nameIt = datasourceManager.getTableDataNameIterator(); |
|
||||||
Iterator<String> procedurenameIt = datasourceManager.getProcedureNameIterator(); |
/** |
||||||
List<NameObject> nameObjectList = new ArrayList<NameObject>(); |
* Populate. |
||||||
while (nameIt.hasNext()) { |
*/ |
||||||
String name = nameIt.next(); |
@Override |
||||||
nameObjectList.add(new NameObject(name, datasourceManager.getTableData(name))); |
public void populate(DatasourceManagerProvider datasourceManager) { |
||||||
} |
Iterator<String> nameIt = datasourceManager.getTableDataNameIterator(); |
||||||
while (procedurenameIt.hasNext()) { |
Iterator<String> procedurenameIt = datasourceManager.getProcedureNameIterator(); |
||||||
String name = procedurenameIt.next(); |
List<NameObject> nameObjectList = new ArrayList<NameObject>(); |
||||||
nameObjectList.add(new NameObject(name, datasourceManager.getProcedureByName(name))); |
while (nameIt.hasNext()) { |
||||||
} |
String name = nameIt.next(); |
||||||
|
nameObjectList.add(new NameObject(name, datasourceManager.getTableData(name))); |
||||||
populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); |
} |
||||||
} |
while (procedurenameIt.hasNext()) { |
||||||
|
String name = procedurenameIt.next(); |
||||||
public void update(DatasourceManagerProvider datasourceManager) { |
nameObjectList.add(new NameObject(name, datasourceManager.getProcedureByName(name))); |
||||||
datasourceManager.clearAllTableData(); |
} |
||||||
datasourceManager.clearAllProcedure(); |
|
||||||
Nameable[] tableDataArray = this.update(); |
populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); |
||||||
for (int i = 0; i < tableDataArray.length; i++) { |
} |
||||||
NameObject nameObject = (NameObject) tableDataArray[i]; |
|
||||||
datasourceManager.putTableData(nameObject.getName(), (TableData) nameObject.getObject()); |
@Override |
||||||
} |
public void update(DatasourceManagerProvider datasourceManager) { |
||||||
} |
datasourceManager.clearAllTableData(); |
||||||
|
datasourceManager.clearAllProcedure(); |
||||||
public void update(TableDataSource tds) { |
Nameable[] tableDataArray = this.update(); |
||||||
tds.clearAllTableData(); |
for (int i = 0; i < tableDataArray.length; i++) { |
||||||
|
NameObject nameObject = (NameObject) tableDataArray[i]; |
||||||
Nameable[] tableDataArray = this.update(); |
datasourceManager.putTableData(nameObject.getName(), (TableData) nameObject.getObject()); |
||||||
for (int i = 0; i < tableDataArray.length; i++) { |
} |
||||||
NameObject nameObject = (NameObject) tableDataArray[i]; |
} |
||||||
tds.putTableData(nameObject.getName(), (TableData) nameObject.getObject()); |
|
||||||
} |
@Override |
||||||
} |
public void update(TableDataSource tds) { |
||||||
|
tds.clearAllTableData(); |
||||||
/** |
|
||||||
* 判断数据集是否重名 |
Nameable[] tableDataArray = this.update(); |
||||||
*/ |
for (int i = 0; i < tableDataArray.length; i++) { |
||||||
public void checkValid() throws Exception { |
NameObject nameObject = (NameObject) tableDataArray[i]; |
||||||
List<String> exsitTableDataNameList = new ArrayList<String>(); |
tds.putTableData(nameObject.getName(), (TableData) nameObject.getObject()); |
||||||
// _denny: 判断是否有重复的数据集名
|
} |
||||||
checkRepeatedDSName(exsitTableDataNameList); |
} |
||||||
|
|
||||||
Nameable[] tableDataArray = this.update(); |
/** |
||||||
for (int i = 0; i < tableDataArray.length; i++) { |
* 判断数据集是否重名 |
||||||
NameObject nameObject = (NameObject) tableDataArray[i]; |
*/ |
||||||
|
@Override |
||||||
if (exsitTableDataNameList.contains(nameObject.getName())) { |
public void checkValid() throws Exception { |
||||||
String[] waring = new String[]{"TableData", "Error_TableDataNameRepeat"}; |
List<String> exsitTableDataNameList = new ArrayList<String>(); |
||||||
String[] sign = new String[]{": " + nameObject.getName()}; |
// _denny: 判断是否有重复的数据集名
|
||||||
throw new Exception(Inter.getLocText(waring, sign)); |
checkRepeatedDSName(exsitTableDataNameList); |
||||||
} |
|
||||||
|
Nameable[] tableDataArray = this.update(); |
||||||
exsitTableDataNameList.add(nameObject.getName()); |
for (int i = 0; i < tableDataArray.length; i++) { |
||||||
} |
NameObject nameObject = (NameObject) tableDataArray[i]; |
||||||
} |
|
||||||
|
if (exsitTableDataNameList.contains(nameObject.getName())) { |
||||||
protected void checkRepeatedDSName(List<String> exsitTableDataNameList) { |
String[] waring = new String[]{"TableData", "Error_TableDataNameRepeat"}; |
||||||
} |
String[] sign = new String[]{": " + nameObject.getName()}; |
||||||
|
throw new Exception(Inter.getLocText(waring, sign)); |
||||||
/** |
} |
||||||
* 在JJControlPane的左侧Tree里面选中某一Item |
|
||||||
* |
exsitTableDataNameList.add(nameObject.getName()); |
||||||
* @param name 被选择的Item名称 |
} |
||||||
*/ |
} |
||||||
public void selectName(String name) { |
|
||||||
this.setSelectedName(name); |
protected void checkRepeatedDSName(List<String> exsitTableDataNameList) { |
||||||
} |
} |
||||||
|
|
||||||
public Map<String, String> getDsNameChangedMap() { |
/** |
||||||
return this.dsNameChangedMap; |
* 在JJControlPane的左侧Tree里面选中某一Item |
||||||
} |
* |
||||||
|
* @param name 被选择的Item名称 |
||||||
|
*/ |
||||||
|
public void selectName(String name) { |
||||||
|
this.setSelectedName(name); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Map<String, String> getDsNameChangedMap() { |
||||||
|
return this.dsNameChangedMap; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public JPanel getPanel() { |
||||||
|
return this; |
||||||
|
} |
||||||
} |
} |
@ -0,0 +1,35 @@ |
|||||||
|
package com.fr.design.extra.exe; |
||||||
|
|
||||||
|
import com.fr.design.extra.Process; |
||||||
|
import com.fr.general.SiteCenter; |
||||||
|
import com.fr.general.http.HttpClient; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by vito on 16/5/16. |
||||||
|
*/ |
||||||
|
public class GetPluginCategoriesExecutor implements Executor { |
||||||
|
private String result = "[]"; |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getTaskFinishMessage() { |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Command[] getCommands() { |
||||||
|
return new Command[]{ |
||||||
|
new Command() { |
||||||
|
@Override |
||||||
|
public String getExecuteMessage() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void run(Process<String> process) { |
||||||
|
HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("plugin.category")); |
||||||
|
result = httpClient.getResponseText(); |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,22 @@ |
|||||||
|
package com.fr.design.fun; |
||||||
|
|
||||||
|
import com.fr.design.mainframe.backgroundpane.BackgroundQuickPane; |
||||||
|
import com.fr.stable.fun.Level; |
||||||
|
import com.fr.stable.fun.Provider; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 16/5/18. |
||||||
|
* 背景设置界面接口,用于扩展设置更多类型的背景 |
||||||
|
*/ |
||||||
|
public interface BackgroundQuickUIProvider extends Level, Provider { |
||||||
|
|
||||||
|
String MARK_STRING = "BackgroundQuickUIProvider"; |
||||||
|
|
||||||
|
int CURRENT_LEVEL = 1; |
||||||
|
|
||||||
|
/** |
||||||
|
* 背景设置界面 |
||||||
|
* @return 设置界面 |
||||||
|
*/ |
||||||
|
BackgroundQuickPane appearanceForBackground(); |
||||||
|
} |
@ -0,0 +1,34 @@ |
|||||||
|
package com.fr.design.fun; |
||||||
|
|
||||||
|
import com.fr.design.style.background.BackgroundDetailPane; |
||||||
|
import com.fr.general.Background; |
||||||
|
import com.fr.stable.fun.Level; |
||||||
|
import com.fr.stable.fun.Provider; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 16/5/18. |
||||||
|
*/ |
||||||
|
public interface BackgroundUIProvider extends Level, Provider { |
||||||
|
|
||||||
|
String MARK_STRING = "BackgroundUIProvider"; |
||||||
|
|
||||||
|
int CURRENT_LEVEL = 1; |
||||||
|
|
||||||
|
/** |
||||||
|
* 对应的背景具体类型 |
||||||
|
* @return 背景 |
||||||
|
*/ |
||||||
|
Class<? extends Background> targetClass(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 背景设置界面 |
||||||
|
* @return 界面 |
||||||
|
*/ |
||||||
|
Class<? extends BackgroundDetailPane> targetUIClass(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 标题 |
||||||
|
* @return 在设计界面上这个选项的显示标题 |
||||||
|
*/ |
||||||
|
String targetTitle(); |
||||||
|
} |
@ -0,0 +1,36 @@ |
|||||||
|
package com.fr.design.fun; |
||||||
|
|
||||||
|
import com.fr.design.DesignModelAdapter; |
||||||
|
import com.fr.design.data.BasicTableDataTreePane; |
||||||
|
import com.fr.design.data.datapane.TableDataPaneController; |
||||||
|
import com.fr.design.menu.ShortCut; |
||||||
|
import com.fr.stable.fun.Level; |
||||||
|
|
||||||
|
/** |
||||||
|
* 自定义的模板(服务器)数据集的树样式接口 el:分组样式 |
||||||
|
* Coder: zack |
||||||
|
* Date: 2016/4/18 |
||||||
|
* Time: 9:04 |
||||||
|
*/ |
||||||
|
public interface TableDataPaneProcessor extends Level { |
||||||
|
String XML_TAG = "TableDataPaneProcessor"; |
||||||
|
|
||||||
|
int CURRENT_LEVEL = 1; |
||||||
|
/** |
||||||
|
* 创建数据集面板 |
||||||
|
* @return 数据集面板 |
||||||
|
*/ |
||||||
|
BasicTableDataTreePane createTableDataTreePane(DesignModelAdapter<?, ?> tc); |
||||||
|
|
||||||
|
/** |
||||||
|
* 服务器数据集面板(模板数据集面板) |
||||||
|
* @return 服务器数据集面板 |
||||||
|
*/ |
||||||
|
TableDataPaneController createServerTableDataPane(DesignModelAdapter<?, ?> tc); |
||||||
|
|
||||||
|
/** |
||||||
|
* 自定义服务器数据集菜单项 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
ShortCut createServerTDAction(); |
||||||
|
} |
@ -1,23 +0,0 @@ |
|||||||
package com.fr.design.fun; |
|
||||||
|
|
||||||
import com.fr.design.DesignModelAdapter; |
|
||||||
import com.fr.design.data.BasicTableDataTreePane; |
|
||||||
import com.fr.stable.fun.Level; |
|
||||||
|
|
||||||
/** |
|
||||||
* 自定义的模板(服务器)数据集的树样式接口 el:分组样式 |
|
||||||
* Coder: zack |
|
||||||
* Date: 2016/4/18 |
|
||||||
* Time: 9:04 |
|
||||||
*/ |
|
||||||
public interface TableDataTreePaneProcessor extends Level { |
|
||||||
String XML_TAG = "TableDataTreePaneProcessor"; |
|
||||||
|
|
||||||
int CURRENT_LEVEL = 1; |
|
||||||
/** |
|
||||||
* 创建数据集面板 |
|
||||||
* @return 数据集面板 |
|
||||||
*/ |
|
||||||
BasicTableDataTreePane createTableDataTreePane(DesignModelAdapter<?, ?> tc); |
|
||||||
|
|
||||||
} |
|
@ -0,0 +1,20 @@ |
|||||||
|
package com.fr.design.fun.impl; |
||||||
|
|
||||||
|
import com.fr.design.fun.BackgroundQuickUIProvider; |
||||||
|
import com.fr.stable.fun.impl.AbstractProvider; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 16/5/18. |
||||||
|
*/ |
||||||
|
public abstract class AbstractBackgroundQuickUIProvider extends AbstractProvider implements BackgroundQuickUIProvider { |
||||||
|
|
||||||
|
@Override |
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String mark4Provider() { |
||||||
|
return getClass().getName(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,20 @@ |
|||||||
|
package com.fr.design.fun.impl; |
||||||
|
|
||||||
|
import com.fr.design.fun.BackgroundUIProvider; |
||||||
|
import com.fr.stable.fun.impl.AbstractProvider; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 16/5/18. |
||||||
|
*/ |
||||||
|
public abstract class AbstractBackgroundUIProvider extends AbstractProvider implements BackgroundUIProvider { |
||||||
|
|
||||||
|
@Override |
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String mark4Provider() { |
||||||
|
return getClass().getName(); |
||||||
|
} |
||||||
|
} |
@ -1,13 +1,13 @@ |
|||||||
package com.fr.design.fun.impl; |
package com.fr.design.fun.impl; |
||||||
|
|
||||||
import com.fr.design.fun.TableDataTreePaneProcessor; |
import com.fr.design.fun.TableDataPaneProcessor; |
||||||
|
|
||||||
/** |
/** |
||||||
* Coder: zack |
* Coder: zack |
||||||
* Date: 2016/4/18 |
* Date: 2016/4/18 |
||||||
* Time: 10:30 |
* Time: 10:30 |
||||||
*/ |
*/ |
||||||
public abstract class AbstractTDTreePaneProcessor implements TableDataTreePaneProcessor { |
public abstract class AbstractTDPaneProcessor implements TableDataPaneProcessor { |
||||||
@Override |
@Override |
||||||
public int currentAPILevel() { |
public int currentAPILevel() { |
||||||
return CURRENT_LEVEL; |
return CURRENT_LEVEL; |
@ -0,0 +1,966 @@ |
|||||||
|
package com.fr.design.gui.controlpane; |
||||||
|
|
||||||
|
import com.fr.base.BaseUtils; |
||||||
|
import com.fr.base.FRContext; |
||||||
|
import com.fr.design.actions.UpdateAction; |
||||||
|
import com.fr.design.beans.BasicBeanPane; |
||||||
|
import com.fr.design.data.tabledata.tabledatapane.GlobalMultiTDTableDataPane; |
||||||
|
import com.fr.design.data.tabledata.tabledatapane.GlobalTreeTableDataPane; |
||||||
|
import com.fr.design.data.tabledata.tabledatapane.MultiTDTableDataPane; |
||||||
|
import com.fr.design.data.tabledata.tabledatapane.TreeTableDataPane; |
||||||
|
import com.fr.design.file.HistoryTemplateListPane; |
||||||
|
import com.fr.design.gui.icontainer.UIScrollPane; |
||||||
|
import com.fr.design.gui.ilist.JNameEdList; |
||||||
|
import com.fr.design.gui.ilist.ListModelElement; |
||||||
|
import com.fr.design.gui.ilist.ModNameActionListener; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.mainframe.JTemplate; |
||||||
|
import com.fr.design.menu.LineSeparator; |
||||||
|
import com.fr.design.menu.MenuDef; |
||||||
|
import com.fr.design.menu.ShortCut; |
||||||
|
import com.fr.design.menu.ToolBarDef; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
import com.fr.general.Inter; |
||||||
|
import com.fr.stable.ArrayUtils; |
||||||
|
import com.fr.stable.Nameable; |
||||||
|
import com.fr.stable.core.PropertyChangeAdapter; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import javax.swing.event.ListSelectionEvent; |
||||||
|
import javax.swing.event.ListSelectionListener; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.MouseAdapter; |
||||||
|
import java.awt.event.MouseEvent; |
||||||
|
import java.awt.event.MouseListener; |
||||||
|
import java.lang.reflect.Constructor; |
||||||
|
import java.lang.reflect.InvocationTargetException; |
||||||
|
import java.util.Arrays; |
||||||
|
import java.util.Comparator; |
||||||
|
|
||||||
|
public abstract class JListControlPane extends JControlPane { |
||||||
|
public static final String LIST_NAME = "JControl_List"; |
||||||
|
|
||||||
|
protected JNameEdList nameableList; |
||||||
|
protected int editingIndex; |
||||||
|
protected String selectedName; |
||||||
|
private boolean isNameRepeated = false; |
||||||
|
|
||||||
|
public JListControlPane() { |
||||||
|
this.initComponentPane(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected JPanel createControlUpdatePane() { |
||||||
|
return new JControlUpdatePane(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 生成添加按钮的NameableCreator |
||||||
|
* |
||||||
|
* @return 按钮的NameableCreator |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public abstract NameableCreator[] createNameableCreators(); |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
protected void initLeftPane(JPanel leftPane) { |
||||||
|
nameableList = createJNameList(); |
||||||
|
nameableList.setName(LIST_NAME); |
||||||
|
leftPane.add(new UIScrollPane(nameableList), BorderLayout.CENTER); |
||||||
|
|
||||||
|
|
||||||
|
nameableList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
||||||
|
nameableList.addMouseListener(listMouseListener); |
||||||
|
nameableList.addListSelectionListener(new ListSelectionListener() { |
||||||
|
public void valueChanged(ListSelectionEvent evt) { |
||||||
|
// richie:避免多次update和populate大大降低效率
|
||||||
|
if (!evt.getValueIsAdjusting()) { |
||||||
|
// shoc 切换的时候加检验
|
||||||
|
if (hasInvalid(false)) { |
||||||
|
return; |
||||||
|
} |
||||||
|
((JControlUpdatePane) JListControlPane.this.controlUpdatePane).update(); |
||||||
|
((JControlUpdatePane) JListControlPane.this.controlUpdatePane).populate(); |
||||||
|
JListControlPane.this.checkButtonEnabled(); |
||||||
|
} |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
public JNameEdList createJNameList() { |
||||||
|
JNameEdList nameEdList = new JNameEdList(new DefaultListModel()) { |
||||||
|
@Override |
||||||
|
protected void doAfterLostFocus() { |
||||||
|
JListControlPane.this.updateControlUpdatePane(); |
||||||
|
} |
||||||
|
}; |
||||||
|
nameEdList.setCellRenderer(new NameableListCellRenderer()); |
||||||
|
return nameEdList; |
||||||
|
} |
||||||
|
|
||||||
|
public void updateControlUpdatePane() { |
||||||
|
((JControlUpdatePane) controlUpdatePane).update(); |
||||||
|
} |
||||||
|
|
||||||
|
protected void doWhenPopulate(BasicBeanPane beanPane) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected ShortCut4JControlPane addItemShortCut() { |
||||||
|
ShortCut addItemShortCut; |
||||||
|
NameableCreator[] creators = creators(); |
||||||
|
if (creators.length == 1) { |
||||||
|
addItemShortCut = new AddItemUpdateAction(creators); |
||||||
|
} else { |
||||||
|
addItemShortCut = new AddItemMenuDef(creators); |
||||||
|
} |
||||||
|
return new AbsoluteEnableShortCut(addItemShortCut); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected ShortCut4JControlPane removeItemShortCut() { |
||||||
|
return new NormalEnableShortCut(new RemoveItemAction()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected ShortCut4JControlPane copyItemShortCut() { |
||||||
|
return new NormalEnableShortCut(new CopyItemAction()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected ShortCut4JControlPane moveUpItemShortCut() { |
||||||
|
return new NormalEnableShortCut(new MoveUpItemAction()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected ShortCut4JControlPane moveDownItemShortCut() { |
||||||
|
return new NormalEnableShortCut(new MoveDownItemAction()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected ShortCut4JControlPane sortItemShortCut() { |
||||||
|
return new NormalEnableShortCut(new SortItemAction()); |
||||||
|
} |
||||||
|
|
||||||
|
public void setNameListEditable(boolean editable) { |
||||||
|
this.nameableList.setEditable(editable); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Nameable[] update() { |
||||||
|
java.util.List<Nameable> res = new java.util.ArrayList<Nameable>(); |
||||||
|
((JControlUpdatePane) this.controlUpdatePane).update(); |
||||||
|
DefaultListModel listModel = (DefaultListModel) this.nameableList.getModel(); |
||||||
|
for (int i = 0, len = listModel.getSize(); i < len; i++) { |
||||||
|
res.add(((ListModelElement) listModel.getElementAt(i)).wrapper); |
||||||
|
} |
||||||
|
|
||||||
|
return res.toArray(new Nameable[res.size()]); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populate(Nameable[] nameableArray) { |
||||||
|
DefaultListModel listModel = (DefaultListModel) this.nameableList.getModel(); |
||||||
|
listModel.removeAllElements(); |
||||||
|
if (ArrayUtils.isEmpty(nameableArray)) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
for (Nameable aNameableArray : nameableArray) { |
||||||
|
listModel.addElement(new ListModelElement(aNameableArray)); |
||||||
|
} |
||||||
|
|
||||||
|
if (listModel.size() > 0) { |
||||||
|
this.nameableList.setSelectedIndex(0); |
||||||
|
} |
||||||
|
this.checkButtonEnabled(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 添加名字改变时的listener |
||||||
|
* |
||||||
|
* @param l 名字改变时的监听 |
||||||
|
*/ |
||||||
|
public void addModNameActionListener(ModNameActionListener l) { |
||||||
|
this.nameableList.addModNameActionListener(l); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 添加Editinglistener |
||||||
|
* |
||||||
|
* @param l 监听 |
||||||
|
*/ |
||||||
|
public void addEditingListner(PropertyChangeAdapter l) { |
||||||
|
this.nameableList.addEditingListner(l); |
||||||
|
} |
||||||
|
|
||||||
|
/* |
||||||
|
* 刷新当前的选中的UpdatePane |
||||||
|
*/ |
||||||
|
protected void populateSelectedValue() { |
||||||
|
((JControlUpdatePane) JListControlPane.this.controlUpdatePane).populate(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 根据name,选中JNameEdList中的item |
||||||
|
*/ |
||||||
|
public void setSelectedName(String name) { |
||||||
|
DefaultListModel listModel = (DefaultListModel) this.nameableList.getModel(); |
||||||
|
for (int i = 0, len = listModel.getSize(); i < len; i++) { |
||||||
|
Nameable item = ((ListModelElement) listModel.getElementAt(i)).wrapper; |
||||||
|
if (ComparatorUtils.equals(name, item.getName())) { |
||||||
|
this.nameableList.setSelectedIndex(i); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public String getEditingName() { |
||||||
|
return this.nameableList.getEditingName(); |
||||||
|
} |
||||||
|
|
||||||
|
public Object getEditingType() { |
||||||
|
return this.nameableList.getAllTypes()[editingIndex]; |
||||||
|
} |
||||||
|
|
||||||
|
public void setWarnigText(int index) { |
||||||
|
this.nameableList.setWarnigText(index); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取选中的名字 |
||||||
|
*/ |
||||||
|
public String getSelectedName() { |
||||||
|
ListModelElement el = (ListModelElement) this.nameableList.getSelectedValue(); |
||||||
|
|
||||||
|
return el == null ? null : el.wrapper.getName(); |
||||||
|
} |
||||||
|
|
||||||
|
protected boolean isNameRepeted(java.util.List[] list, String name) { |
||||||
|
for (int i = 0; i < list.length; i++) { |
||||||
|
if (list[i].contains(name)) { |
||||||
|
isNameRepeated = true; |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
isNameRepeated = false; |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 名字是否重复 |
||||||
|
* |
||||||
|
* @return 重复则返回true |
||||||
|
*/ |
||||||
|
public boolean isNameRepeated() { |
||||||
|
return isNameRepeated; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 添加 Nameable |
||||||
|
* |
||||||
|
* @param nameable 添加的Nameable |
||||||
|
* @param index 序号 |
||||||
|
*/ |
||||||
|
public void addNameable(Nameable nameable, int index) { |
||||||
|
JNameEdList nameEdList = JListControlPane.this.nameableList; |
||||||
|
DefaultListModel model = (DefaultListModel) nameEdList.getModel(); |
||||||
|
|
||||||
|
ListModelElement el = new ListModelElement(nameable); |
||||||
|
model.add(index, el); |
||||||
|
nameableList.setSelectedIndex(index); |
||||||
|
nameableList.ensureIndexIsVisible(index); |
||||||
|
|
||||||
|
nameEdList.repaint(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否重命名 |
||||||
|
* |
||||||
|
* @return 是则true |
||||||
|
*/ |
||||||
|
public boolean isContainsRename() { |
||||||
|
String rename = Inter.getLocText("FR-Please_Rename") + "!"; |
||||||
|
String[] names = this.nameableList.getAllNames(); |
||||||
|
for (int i = names.length - 1; i >= 0; i--) { |
||||||
|
if (ComparatorUtils.equals(names[i], rename)) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
protected DefaultListModel getModel() { |
||||||
|
return (DefaultListModel) JListControlPane.this.nameableList.getModel(); |
||||||
|
} |
||||||
|
|
||||||
|
private String createUnrepeatedCopyName(String suffix) { |
||||||
|
DefaultListModel model = this.getModel(); |
||||||
|
String[] names = new String[model.getSize()]; |
||||||
|
for (int i = 0; i < model.size(); i++) { |
||||||
|
names[i] = ((ListModelElement) model.get(i)).wrapper.getName(); |
||||||
|
} |
||||||
|
String lastName = "CopyOf" + suffix; |
||||||
|
while (ArrayUtils.contains(names, lastName)) { |
||||||
|
lastName = "CopyOf" + lastName; |
||||||
|
} |
||||||
|
return lastName; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 生成不重复的名字 |
||||||
|
* |
||||||
|
* @param prefix 名字前缀 |
||||||
|
* @return 名字 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public String createUnrepeatedName(String prefix) { |
||||||
|
DefaultListModel model = this.getModel(); |
||||||
|
Nameable[] all = new Nameable[model.getSize()]; |
||||||
|
for (int i = 0; i < model.size(); i++) { |
||||||
|
all[i] = ((ListModelElement) model.get(i)).wrapper; |
||||||
|
} |
||||||
|
// richer:生成的名字从1开始. kunsnat: 添加属性从0开始.
|
||||||
|
int count = all.length + 1; |
||||||
|
while (true) { |
||||||
|
String name_test = prefix + count; |
||||||
|
boolean repeated = false; |
||||||
|
for (int i = 0, len = model.size(); i < len; i++) { |
||||||
|
Nameable nameable = all[i]; |
||||||
|
if (ComparatorUtils.equals(nameable.getName(), name_test)) { |
||||||
|
repeated = true; |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if (!repeated) { |
||||||
|
return name_test; |
||||||
|
} |
||||||
|
|
||||||
|
count++; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 增加项的UpdateAction |
||||||
|
*/ |
||||||
|
protected class AddItemUpdateAction extends UpdateAction { |
||||||
|
final NameableCreator creator; |
||||||
|
|
||||||
|
public AddItemUpdateAction(NameableCreator[] creators) { |
||||||
|
this.creator = creators[0]; |
||||||
|
this.setName(Inter.getLocText("FR-Action_Add")); |
||||||
|
this.setMnemonic('A'); |
||||||
|
this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png")); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
Nameable nameable = creator.createNameable(JListControlPane.this); |
||||||
|
|
||||||
|
JListControlPane.this.addNameable(nameable, getModel().getSize()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/* |
||||||
|
* 增加项的MenuDef |
||||||
|
*/ |
||||||
|
protected class AddItemMenuDef extends MenuDef { |
||||||
|
public AddItemMenuDef(NameableCreator[] creators) { |
||||||
|
this.setName(Inter.getLocText("FR-Action_Add")); |
||||||
|
this.setMnemonic('A'); |
||||||
|
this.setIconPath("/com/fr/design/images/control/addPopup.png"); |
||||||
|
wrapActionListener(creators); |
||||||
|
} |
||||||
|
|
||||||
|
private void wrapActionListener(NameableCreator[] creators) { |
||||||
|
for (final NameableCreator creator : creators) { |
||||||
|
if (!whetherAdd(creator.menuName())) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
boolean isTrue = ComparatorUtils.equals(creator.menuName(), Inter.getLocText("Datasource-Stored_Procedure")) || |
||||||
|
ComparatorUtils.equals(creator.menuName(), Inter.getLocText("DS-Relation_TableData")) || ComparatorUtils.equals(creator.menuName(), Inter.getLocText("DS-Multi_Dimensional_Database")); |
||||||
|
if (isTrue) { |
||||||
|
this.addShortCut(new LineSeparator()); |
||||||
|
} |
||||||
|
this.addShortCut(new UpdateAction() { |
||||||
|
{ |
||||||
|
this.setName(creator.menuName()); |
||||||
|
Icon icon = creator.menuIcon(); |
||||||
|
if (icon != null) { |
||||||
|
this.setSmallIcon(icon); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
if (hasInvalid(true)) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
Nameable nameable = creator.createNameable(JListControlPane.this); |
||||||
|
|
||||||
|
JListControlPane.this.addNameable(nameable, getModel().getSize()); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private boolean whetherAdd(String itemName) { |
||||||
|
JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); |
||||||
|
if (jTemplate == null) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
//先屏蔽掉这个,之后还有别的
|
||||||
|
String[] names = {Inter.getLocText("FR-Hyperlink_Chart_Float")}; |
||||||
|
for (String name : names) { |
||||||
|
if (!jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, name)) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
String formName = Inter.getLocText("Hyperlink-Form_link"); |
||||||
|
return !(jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, formName)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/* |
||||||
|
* 移除item |
||||||
|
*/ |
||||||
|
private class RemoveItemAction extends UpdateAction { |
||||||
|
public RemoveItemAction() { |
||||||
|
this.setName(Inter.getLocText("FR-Action_Remove")); |
||||||
|
this.setMnemonic('R'); |
||||||
|
this.setSmallIcon(BaseUtils |
||||||
|
.readIcon("/com/fr/base/images/cell/control/remove.png")); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent evt) { |
||||||
|
try { |
||||||
|
JListControlPane.this.nameableList.getCellEditor() |
||||||
|
.stopCellEditing(); |
||||||
|
} catch (Exception ignored) { |
||||||
|
} |
||||||
|
// bug:在选中一个NameObject并删除,会遗留下Name.
|
||||||
|
doBeforeRemove(); |
||||||
|
if (GUICoreUtils.removeJListSelectedNodes(SwingUtilities |
||||||
|
.getWindowAncestor(JListControlPane.this), nameableList)) { |
||||||
|
checkButtonEnabled(); |
||||||
|
doAfterRemove(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/* |
||||||
|
* CopyItem |
||||||
|
*/ |
||||||
|
private class CopyItemAction extends UpdateAction { |
||||||
|
public CopyItemAction() { |
||||||
|
this.setName(Inter.getLocText("FR-Action_Copy")); |
||||||
|
this.setMnemonic('C'); |
||||||
|
this.setSmallIcon(BaseUtils |
||||||
|
.readIcon("/com/fr/base/images/cell/control/copy.png")); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent evt) { |
||||||
|
// p:选中的值.
|
||||||
|
ListModelElement selectedValue = (ListModelElement) nameableList.getSelectedValue(); |
||||||
|
if (selectedValue == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
((JControlUpdatePane) controlUpdatePane).update(); |
||||||
|
|
||||||
|
Nameable selectedNameable = selectedValue.wrapper; |
||||||
|
|
||||||
|
// p: 用反射机制实现
|
||||||
|
try { |
||||||
|
Nameable newNameable = (Nameable) BaseUtils.cloneObject(selectedNameable); |
||||||
|
newNameable.setName(createUnrepeatedCopyName(selectedNameable.getName())); |
||||||
|
|
||||||
|
JListControlPane.this.addNameable(newNameable, nameableList.getSelectedIndex() + 1); |
||||||
|
} catch (Exception e) { |
||||||
|
FRContext.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/* |
||||||
|
* 上移Item |
||||||
|
*/ |
||||||
|
private class MoveUpItemAction extends UpdateAction { |
||||||
|
public MoveUpItemAction() { |
||||||
|
this.setName(Inter.getLocText("Utils-Move_Up")); |
||||||
|
this.setMnemonic('U'); |
||||||
|
this.setSmallIcon(BaseUtils |
||||||
|
.readIcon("/com/fr/design/images/control/up.png")); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent evt) { |
||||||
|
int selectedIndex = nameableList.getSelectedIndex(); |
||||||
|
if (selectedIndex == -1) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
// 上移
|
||||||
|
if (selectedIndex > 0) { |
||||||
|
DefaultListModel listModel = (DefaultListModel) nameableList |
||||||
|
.getModel(); |
||||||
|
|
||||||
|
Object selecteObj1 = listModel.get(selectedIndex - 1); |
||||||
|
listModel.set(selectedIndex - 1, listModel.get(selectedIndex)); |
||||||
|
listModel.set(selectedIndex, selecteObj1); |
||||||
|
|
||||||
|
nameableList.setSelectedIndex(selectedIndex - 1); |
||||||
|
nameableList.ensureIndexIsVisible(selectedIndex - 1); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/* |
||||||
|
* 下移Item |
||||||
|
*/ |
||||||
|
private class MoveDownItemAction extends UpdateAction { |
||||||
|
public MoveDownItemAction() { |
||||||
|
this.setName(Inter.getLocText("Utils-Move_Down")); |
||||||
|
this.setMnemonic('D'); |
||||||
|
this.setSmallIcon(BaseUtils |
||||||
|
.readIcon("/com/fr/design/images/control/down.png")); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent evt) { |
||||||
|
int selectedIndex = nameableList.getSelectedIndex(); |
||||||
|
if (selectedIndex == -1) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
if (selectedIndex < nameableList.getModel().getSize() - 1) { |
||||||
|
DefaultListModel listModel = (DefaultListModel) nameableList |
||||||
|
.getModel(); |
||||||
|
|
||||||
|
Object selecteObj1 = listModel.get(selectedIndex + 1); |
||||||
|
listModel.set(selectedIndex + 1, listModel.get(selectedIndex)); |
||||||
|
listModel.set(selectedIndex, selecteObj1); |
||||||
|
|
||||||
|
nameableList.setSelectedIndex(selectedIndex + 1); |
||||||
|
nameableList.ensureIndexIsVisible(selectedIndex + 1); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private class SortItemAction extends UpdateAction { |
||||||
|
private boolean isAtoZ = false; |
||||||
|
|
||||||
|
public SortItemAction() { |
||||||
|
this.setName(Inter.getLocText("FR-Action_Sort")); |
||||||
|
this.setMnemonic('S'); |
||||||
|
this.setSmallIcon(BaseUtils |
||||||
|
.readIcon("/com/fr/design/images/control/sortAsc.png")); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent evt) { |
||||||
|
// p:选中的值.
|
||||||
|
Object selectedValue = nameableList.getSelectedValue(); |
||||||
|
|
||||||
|
DefaultListModel listModel = (DefaultListModel) nameableList |
||||||
|
.getModel(); |
||||||
|
Nameable[] nameableArray = new Nameable[listModel.getSize()]; |
||||||
|
if (nameableArray.length <= 0) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
for (int i = 0; i < listModel.getSize(); i++) { |
||||||
|
nameableArray[i] = ((ListModelElement) listModel.getElementAt(i)).wrapper; |
||||||
|
} |
||||||
|
|
||||||
|
// p:排序.
|
||||||
|
if (isAtoZ) { |
||||||
|
Comparator<Nameable> nameableComparator = new Comparator<Nameable>() { |
||||||
|
@Override |
||||||
|
public int compare(Nameable o1, Nameable o2) { |
||||||
|
return -ComparatorUtils.compare(o1.getName(), o2 |
||||||
|
.getName()); |
||||||
|
} |
||||||
|
}; |
||||||
|
isAtoZ = !isAtoZ; |
||||||
|
Arrays.sort(nameableArray, nameableComparator); |
||||||
|
} else { |
||||||
|
Comparator<Nameable> nameableComparator = new Comparator<Nameable>() { |
||||||
|
@Override |
||||||
|
public int compare(Nameable o1, Nameable o2) { |
||||||
|
return ComparatorUtils.compare(o1.getName(), o2 |
||||||
|
.getName()); |
||||||
|
} |
||||||
|
}; |
||||||
|
isAtoZ = !isAtoZ; |
||||||
|
Arrays.sort(nameableArray, nameableComparator); |
||||||
|
} |
||||||
|
|
||||||
|
for (int i = 0; i < nameableArray.length; i++) { |
||||||
|
listModel.set(i, new ListModelElement(nameableArray[i])); |
||||||
|
} |
||||||
|
|
||||||
|
// p:需要选中以前的那个值.
|
||||||
|
if (selectedValue != null) { |
||||||
|
nameableList.setSelectedValue(selectedValue, true); |
||||||
|
} |
||||||
|
|
||||||
|
checkButtonEnabled(); |
||||||
|
// p:需要repaint.
|
||||||
|
nameableList.repaint(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/* |
||||||
|
* JNameEdList的鼠标事件 |
||||||
|
*/ |
||||||
|
private MouseListener listMouseListener = new MouseAdapter() { |
||||||
|
@Override |
||||||
|
public void mouseReleased(MouseEvent evt) { |
||||||
|
nameableList.stopEditing(); |
||||||
|
if (evt.getClickCount() >= 2 |
||||||
|
&& SwingUtilities.isLeftMouseButton(evt)) { |
||||||
|
editingIndex = nameableList.getSelectedIndex(); |
||||||
|
selectedName = nameableList.getNameAt(editingIndex); |
||||||
|
nameableList.editItemAt(nameableList.getSelectedIndex()); |
||||||
|
} |
||||||
|
// peter:处理右键的弹出菜单
|
||||||
|
if (!SwingUtilities.isRightMouseButton(evt)) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
// peter: 注意,在checkButtonEnabled()方法里面,设置了所有的Action的Enabled.
|
||||||
|
checkButtonEnabled(); |
||||||
|
|
||||||
|
// p:右键菜单.
|
||||||
|
JPopupMenu popupMenu = new JPopupMenu(); |
||||||
|
|
||||||
|
for (ShortCut4JControlPane sj : getShorts()) { |
||||||
|
sj.getShortCut().intoJPopupMenu(popupMenu); |
||||||
|
} |
||||||
|
|
||||||
|
// peter: 只有弹出菜单有子菜单的时候,才需要弹出来.
|
||||||
|
GUICoreUtils.showPopupMenu(popupMenu, nameableList, evt.getX() - 1, |
||||||
|
evt.getY() - 1); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void mouseMoved(MouseEvent e) { |
||||||
|
|
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* 检查按钮可用状态 Check button enabled. |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void checkButtonEnabled() { |
||||||
|
|
||||||
|
int selectedIndex = nameableList.getSelectedIndex(); |
||||||
|
if (selectedIndex == -1) { |
||||||
|
this.cardLayout.show(cardPane, "SELECT"); |
||||||
|
} else { |
||||||
|
this.cardLayout.show(cardPane, "EDIT"); |
||||||
|
} |
||||||
|
for (ShortCut4JControlPane sj : getShorts()) { |
||||||
|
sj.checkEnable(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/* |
||||||
|
* Nameable的ListCellRenerer |
||||||
|
*/ |
||||||
|
private class NameableListCellRenderer extends |
||||||
|
DefaultListCellRenderer { |
||||||
|
@Override |
||||||
|
public Component getListCellRendererComponent(JList list, Object value, |
||||||
|
int index, boolean isSelected, boolean cellHasFocus) { |
||||||
|
super.getListCellRendererComponent(list, value, index, isSelected, |
||||||
|
cellHasFocus); |
||||||
|
|
||||||
|
if (value instanceof ListModelElement) { |
||||||
|
Nameable wrappee = ((ListModelElement) value).wrapper; |
||||||
|
this.setText(((ListModelElement) value).wrapper.getName()); |
||||||
|
|
||||||
|
boolean iconSet = false; |
||||||
|
for (NameableCreator creator : JListControlPane.this.creators()) { |
||||||
|
if (creator.menuIcon() != null && creator.acceptObject2Populate(wrappee) != null) { |
||||||
|
this.setIcon(creator.menuIcon()); |
||||||
|
this.setToolTipText(creator.createTooltip()); |
||||||
|
iconSet = true; |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
if (!iconSet) { |
||||||
|
this.setIcon(BaseUtils.readIcon("/com/fr/base/images/oem/cpt.png")); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return this; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public class AbsoluteEnableShortCut extends ShortCut4JControlPane { |
||||||
|
public AbsoluteEnableShortCut(ShortCut shortCut) { |
||||||
|
this.shortCut = shortCut; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 检查是否可用 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void checkEnable() { |
||||||
|
this.shortCut.setEnabled(true); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public class NormalEnableShortCut extends ShortCut4JControlPane { |
||||||
|
public NormalEnableShortCut(ShortCut shortCut) { |
||||||
|
this.shortCut = shortCut; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 检查是否可用 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void checkEnable() { |
||||||
|
this.shortCut.setEnabled(getModel() |
||||||
|
.getSize() > 0 |
||||||
|
&& JListControlPane.this.nameableList.getSelectedIndex() != -1); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public class SortEnableShortCut extends ShortCut4JControlPane { |
||||||
|
public SortEnableShortCut(ShortCut shortCut) { |
||||||
|
this.shortCut = shortCut; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 检查是否可用 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void checkEnable() { |
||||||
|
this.shortCut.setEnabled(getModel().getSize() > 1); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public class MoveUpEnableShortCut extends ShortCut4JControlPane { |
||||||
|
public MoveUpEnableShortCut(ShortCut shortCut) { |
||||||
|
this.shortCut = shortCut; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 检查是否可用 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void checkEnable() { |
||||||
|
this.shortCut.setEnabled(getModel().getSize() > 1 |
||||||
|
&& JListControlPane.this.nameableList.getSelectedIndex() > 0); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public class MoveDownEnableShortCut extends ShortCut4JControlPane { |
||||||
|
public MoveDownEnableShortCut(ShortCut shortCut) { |
||||||
|
this.shortCut = shortCut; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 检查是否可用 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void checkEnable() { |
||||||
|
this.shortCut.setEnabled(getModel().getSize() > 1 |
||||||
|
&& JListControlPane.this.nameableList.getSelectedIndex() < JListControlPane.this.nameableList.getModel().getSize() - 1); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private class JControlUpdatePane extends JPanel { |
||||||
|
private CardLayout card; |
||||||
|
private JPanel cardPane; |
||||||
|
private BasicBeanPane[] updatePanes; |
||||||
|
|
||||||
|
private ListModelElement elEditing; |
||||||
|
|
||||||
|
public JControlUpdatePane() { |
||||||
|
initUpdatePane(); |
||||||
|
} |
||||||
|
|
||||||
|
private void initUpdatePane() { |
||||||
|
NameableCreator[] creators = creators(); |
||||||
|
if (creators == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
card = new CardLayout(); |
||||||
|
cardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); |
||||||
|
cardPane.setLayout(card); |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
this.add(cardPane); |
||||||
|
int len = creators.length; |
||||||
|
updatePanes = new BasicBeanPane[len]; |
||||||
|
} |
||||||
|
|
||||||
|
public void populate() { |
||||||
|
ListModelElement el = (ListModelElement) JListControlPane.this.nameableList.getSelectedValue(); |
||||||
|
if (el == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
elEditing = el; |
||||||
|
NameableCreator[] creators = creators(); |
||||||
|
|
||||||
|
for (int i = 0, len = updatePanes.length; i < len; i++) { |
||||||
|
Object ob2Populate = creators[i].acceptObject2Populate(el.wrapper); |
||||||
|
if (ob2Populate != null) { |
||||||
|
if (updatePanes[i] == null) { |
||||||
|
if (isMulti(creators[i].getUpdatePane()) || isTree(creators[i].getUpdatePane())) { |
||||||
|
updatePanes[i] = createPaneByCreators(creators[i], el.wrapper.getName()); |
||||||
|
} else { |
||||||
|
updatePanes[i] = createPaneByCreators(creators[i]); |
||||||
|
} |
||||||
|
cardPane.add(updatePanes[i], String.valueOf(i)); |
||||||
|
} |
||||||
|
card.show(cardPane, String.valueOf(i)); |
||||||
|
updatePanes[i].populateBean(ob2Populate); |
||||||
|
doWhenPopulate(updatePanes[i]); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public boolean isMulti(Class _class) { |
||||||
|
return ComparatorUtils.equals(_class, GlobalMultiTDTableDataPane.class) || ComparatorUtils.equals(_class, MultiTDTableDataPane.class); |
||||||
|
} |
||||||
|
|
||||||
|
public boolean isTree(Class _class) { |
||||||
|
return ComparatorUtils.equals(_class, GlobalTreeTableDataPane.class) || ComparatorUtils.equals(_class, TreeTableDataPane.class); |
||||||
|
} |
||||||
|
|
||||||
|
public void update() { |
||||||
|
NameableCreator[] creators = creators(); |
||||||
|
for (int i = 0; i < updatePanes.length; i++) { |
||||||
|
BasicBeanPane pane = updatePanes[i]; |
||||||
|
|
||||||
|
if (pane != null && pane.isVisible()) { |
||||||
|
Object bean = pane.updateBean(); |
||||||
|
if (i < creators.length) { |
||||||
|
creators[i].saveUpdatedBean(elEditing, bean); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void checkValid() throws Exception { |
||||||
|
if (updatePanes != null) { |
||||||
|
for (int i = 0; i < updatePanes.length; i++) { |
||||||
|
if (updatePanes[i] != null) { |
||||||
|
updatePanes[i].checkValid(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
protected BasicBeanPane createPaneByCreators(NameableCreator creator) { |
||||||
|
try { |
||||||
|
return creator.getUpdatePane().newInstance(); |
||||||
|
} catch (InstantiationException e) { |
||||||
|
throw new RuntimeException(e); |
||||||
|
} catch (IllegalAccessException e) { |
||||||
|
throw new RuntimeException(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
protected BasicBeanPane createPaneByCreators(NameableCreator creator, String string) { |
||||||
|
Constructor constructor = null; |
||||||
|
try { |
||||||
|
constructor = creator.getUpdatePane().getDeclaredConstructor(new Class[]{String.class}); |
||||||
|
constructor.setAccessible(true); |
||||||
|
return (BasicBeanPane) constructor.newInstance(string); |
||||||
|
} catch (NoSuchMethodException e) { |
||||||
|
throw new RuntimeException(e); |
||||||
|
} catch (InstantiationException e) { |
||||||
|
throw new RuntimeException(e); |
||||||
|
} catch (IllegalAccessException e) { |
||||||
|
throw new RuntimeException(e); |
||||||
|
} catch (InvocationTargetException e) { |
||||||
|
throw new RuntimeException(e); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
// 选项添加个数有限制等情况下 要求能控制快捷按钮的状态
|
||||||
|
protected void setToolbarDefEnable(int shortCutIndex, int itemIndex, boolean enabled) { |
||||||
|
ToolBarDef toolbarDef = getToolbarDef(); |
||||||
|
if (toolbarDef.getShortCutCount() > shortCutIndex) { |
||||||
|
ShortCut sc = toolbarDef.getShortCut(shortCutIndex); |
||||||
|
if (sc instanceof AddItemMenuDef) { |
||||||
|
AddItemMenuDef am = (AddItemMenuDef) sc; |
||||||
|
if (am.getShortCutCount() > itemIndex) { |
||||||
|
am.getShortCut(itemIndex).setEnabled(enabled); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 检查是否符合规范 |
||||||
|
* |
||||||
|
* @throws Exception |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void checkValid() throws Exception { |
||||||
|
((JControlUpdatePane) this.controlUpdatePane).checkValid(); |
||||||
|
} |
||||||
|
|
||||||
|
private int getInValidIndex() { |
||||||
|
BasicBeanPane[] p = ((JControlUpdatePane) controlUpdatePane).updatePanes; |
||||||
|
if (p != null) { |
||||||
|
for (int i = 0; i < p.length; i++) { |
||||||
|
if (p[i] != null) { |
||||||
|
try { |
||||||
|
p[i].checkValid(); |
||||||
|
} catch (Exception e) { |
||||||
|
return i; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return -1; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected boolean hasInvalid(boolean isAdd) { |
||||||
|
int idx = JListControlPane.this.getInValidIndex(); |
||||||
|
if (isAdd || nameableList.getSelectedIndex() != idx) { |
||||||
|
try { |
||||||
|
checkValid(); |
||||||
|
} catch (Exception exp) { |
||||||
|
JOptionPane.showMessageDialog(JListControlPane.this, exp.getMessage()); |
||||||
|
nameableList.setSelectedIndex(idx); |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
/** |
||||||
|
* 设置选中项 |
||||||
|
* |
||||||
|
* @param index 选中项的序列号 |
||||||
|
*/ |
||||||
|
public void setSelectedIndex(int index) { |
||||||
|
nameableList.setSelectedIndex(index); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -1,148 +1,145 @@ |
|||||||
package com.fr.design.gui.style; |
package com.fr.design.gui.style; |
||||||
|
|
||||||
/* |
import com.fr.base.Style; |
||||||
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved. |
import com.fr.design.ExtraDesignClassManager; |
||||||
*/ |
import com.fr.design.fun.BackgroundQuickUIProvider; |
||||||
|
import com.fr.design.gui.icombobox.UIComboBox; |
||||||
import java.awt.BorderLayout; |
import com.fr.design.mainframe.backgroundpane.*; |
||||||
import java.awt.CardLayout; |
import com.fr.general.Background; |
||||||
import java.awt.Dimension; |
import com.fr.general.Inter; |
||||||
import java.awt.event.ItemEvent; |
|
||||||
import java.awt.event.ItemListener; |
import javax.swing.*; |
||||||
import java.util.ArrayList; |
import javax.swing.event.ChangeEvent; |
||||||
import java.util.List; |
import javax.swing.event.ChangeListener; |
||||||
|
import java.awt.*; |
||||||
import javax.swing.*; |
import java.awt.event.ItemEvent; |
||||||
import javax.swing.event.ChangeEvent; |
import java.awt.event.ItemListener; |
||||||
import javax.swing.event.ChangeListener; |
import java.util.ArrayList; |
||||||
|
|
||||||
import com.fr.base.Style; |
/** |
||||||
import com.fr.design.gui.icombobox.UIComboBox; |
* @author zhou |
||||||
import com.fr.design.mainframe.backgroundpane.BackgroundSettingPane; |
* @since 2012-5-28下午6:22:09 |
||||||
import com.fr.design.mainframe.backgroundpane.ColorBackgroundPane; |
*/ |
||||||
import com.fr.design.mainframe.backgroundpane.ImageBackgroundPane; |
public class BackgroundPane extends AbstractBasicStylePane { |
||||||
import com.fr.design.mainframe.backgroundpane.NullBackgroundPane; |
|
||||||
import com.fr.design.mainframe.backgroundpane.PatternBackgroundPane; |
private UIComboBox typeComboBox; |
||||||
import com.fr.design.mainframe.backgroundpane.TextureBackgroundPane; |
|
||||||
import com.fr.general.Background; |
protected BackgroundQuickPane[] paneList; |
||||||
import com.fr.general.Inter; |
|
||||||
|
public BackgroundPane() { |
||||||
/** |
this.initComponents(); |
||||||
* |
} |
||||||
* @author zhou |
|
||||||
* @since 2012-5-28下午6:22:09 |
protected void initComponents() { |
||||||
*/ |
this.setLayout(new BorderLayout(0, 6)); |
||||||
public class BackgroundPane extends AbstractBasicStylePane { |
typeComboBox = new UIComboBox(); |
||||||
|
final CardLayout cardlayout = new CardLayout(); |
||||||
private UIComboBox typeComboBox; |
this.add(typeComboBox, BorderLayout.NORTH); |
||||||
|
|
||||||
protected List<BackgroundSettingPane> paneList; |
paneList = supportKindsOfBackgroundUI(); |
||||||
|
|
||||||
public BackgroundPane() { |
final JPanel centerPane = new JPanel(cardlayout) { |
||||||
this.initComponents(); |
@Override |
||||||
} |
public Dimension getPreferredSize() {// AUGUST:使用当前面板的的高度
|
||||||
|
int index = typeComboBox.getSelectedIndex(); |
||||||
protected void initComponents() { |
return new Dimension(super.getPreferredSize().width, paneList[index].getPreferredSize().height); |
||||||
this.setLayout(new BorderLayout(0, 6)); |
} |
||||||
typeComboBox = new UIComboBox(); |
}; |
||||||
final CardLayout cardlayout = new CardLayout(); |
for (BackgroundQuickPane pane : paneList) { |
||||||
this.add(typeComboBox, BorderLayout.NORTH); |
typeComboBox.addItem(pane.title4PopupWindow()); |
||||||
|
centerPane.add(pane, pane.title4PopupWindow()); |
||||||
initPaneList(); |
} |
||||||
final JPanel centerPane = new JPanel(cardlayout) { |
this.add(centerPane, BorderLayout.CENTER); |
||||||
@Override |
typeComboBox.addItemListener(new ItemListener() { |
||||||
public Dimension getPreferredSize() {// AUGUST:使用当前面板的的高度
|
|
||||||
int index = typeComboBox.getSelectedIndex(); |
@Override |
||||||
return new Dimension(super.getPreferredSize().width, paneList.get(index).getPreferredSize().height); |
public void itemStateChanged(ItemEvent e) { |
||||||
} |
cardlayout.show(centerPane, (String) typeComboBox.getSelectedItem()); |
||||||
}; |
fireStateChanged(); |
||||||
for (int i = 0; i < paneList.size(); i++) { |
} |
||||||
BackgroundSettingPane pane = paneList.get(i); |
}); |
||||||
typeComboBox.addItem(pane.title4PopupWindow()); |
} |
||||||
centerPane.add(pane, pane.title4PopupWindow()); |
|
||||||
} |
protected BackgroundQuickPane[] supportKindsOfBackgroundUI() { |
||||||
this.add(centerPane, BorderLayout.CENTER); |
java.util.List<BackgroundQuickPane> kinds = new ArrayList<>(); |
||||||
typeComboBox.addItemListener(new ItemListener() { |
kinds.add(new NullBackgroundQuickPane()); |
||||||
|
kinds.add(new ColorBackgroundQuickPane()); |
||||||
@Override |
kinds.add(new TextureBackgroundQuickPane()); |
||||||
public void itemStateChanged(ItemEvent e) { |
kinds.add(new PatternBackgroundQuickPane()); |
||||||
cardlayout.show(centerPane, (String)typeComboBox.getSelectedItem()); |
kinds.add(new ImageBackgroundQuickPane()); |
||||||
fireStateChanged(); |
kinds.add(new GradientBackgroundQuickPane()); |
||||||
} |
BackgroundQuickUIProvider[] providers = ExtraDesignClassManager.getInstance().getBackgroundQuickUIProviders(); |
||||||
}); |
for (BackgroundQuickUIProvider provider : providers) { |
||||||
} |
kinds.add(provider.appearanceForBackground()); |
||||||
|
|
||||||
protected void initPaneList(){ |
} |
||||||
paneList = new ArrayList<BackgroundSettingPane>(); |
return kinds.toArray(new BackgroundQuickPane[kinds.size()]); |
||||||
paneList.add(new NullBackgroundPane()); |
} |
||||||
paneList.add(new ColorBackgroundPane()); |
|
||||||
paneList.add(new TextureBackgroundPane()); |
|
||||||
paneList.add(new PatternBackgroundPane()); |
/** |
||||||
paneList.add(new ImageBackgroundPane()); |
* 事件监听 |
||||||
paneList.add(new GradientPane()); |
* |
||||||
} |
* @param changeListener 事件 |
||||||
|
*/ |
||||||
/** |
public void addChangeListener(ChangeListener changeListener) { |
||||||
* 事件监听 |
listenerList.add(ChangeListener.class, changeListener); |
||||||
* @param changeListener 事件 |
} |
||||||
*/ |
|
||||||
public void addChangeListener(ChangeListener changeListener) { |
/** |
||||||
listenerList.add(ChangeListener.class, changeListener); |
*/ |
||||||
} |
protected void fireStateChanged() { |
||||||
|
Object[] listeners = listenerList.getListenerList(); |
||||||
/** |
ChangeEvent e = null; |
||||||
*/ |
|
||||||
protected void fireStateChanged() { |
for (int i = listeners.length - 2; i >= 0; i -= 2) { |
||||||
Object[] listeners = listenerList.getListenerList(); |
if (listeners[i] == ChangeListener.class) { |
||||||
ChangeEvent e = null; |
if (e == null) { |
||||||
|
e = new ChangeEvent(this); |
||||||
for (int i = listeners.length - 2; i >= 0; i -= 2) { |
} |
||||||
if (listeners[i] == ChangeListener.class) { |
((ChangeListener) listeners[i + 1]).stateChanged(e); |
||||||
if (e == null) { |
} |
||||||
e = new ChangeEvent(this); |
} |
||||||
} |
} |
||||||
((ChangeListener)listeners[i + 1]).stateChanged(e); |
|
||||||
} |
/** |
||||||
} |
* 名称 |
||||||
} |
* |
||||||
|
* @return 名称 |
||||||
/** |
*/ |
||||||
* 名称 |
public String title4PopupWindow() { |
||||||
* @return 名称 |
return Inter.getLocText("FR-Utils_Background"); |
||||||
*/ |
} |
||||||
public String title4PopupWindow() { |
|
||||||
return Inter.getLocText("FR-Utils_Background"); |
/** |
||||||
} |
* Populate background. |
||||||
|
*/ |
||||||
/** |
public void populateBean(Background background) { |
||||||
* Populate background. |
for (int i = 0; i < paneList.length; i++) { |
||||||
*/ |
BackgroundQuickPane pane = paneList[i]; |
||||||
public void populateBean(Background background) { |
if (pane.accept(background)) { |
||||||
for (int i = 0; i < paneList.size(); i++) { |
pane.populateBean(background); |
||||||
BackgroundSettingPane pane = paneList.get(i); |
typeComboBox.setSelectedIndex(i); |
||||||
if (pane.accept(background)) { |
return; |
||||||
pane.populateBean(background); |
} |
||||||
typeComboBox.setSelectedIndex(i); |
} |
||||||
return; |
} |
||||||
} |
|
||||||
} |
/** |
||||||
} |
* Update background. |
||||||
|
*/ |
||||||
/** |
public Background update() { |
||||||
* Update background. |
return paneList[typeComboBox.getSelectedIndex()].updateBean(); |
||||||
*/ |
} |
||||||
public Background update() { |
|
||||||
return paneList.get(typeComboBox.getSelectedIndex()).updateBean(); |
@Override |
||||||
} |
public void populateBean(Style style) { |
||||||
|
this.populateBean(style.getBackground()); |
||||||
@Override |
} |
||||||
public void populateBean(Style style) { |
|
||||||
this.populateBean(style.getBackground()); |
@Override |
||||||
} |
public Style update(Style style) { |
||||||
|
return style.deriveBackground(this.update()); |
||||||
@Override |
} |
||||||
public Style update(Style style) { |
|
||||||
return style.deriveBackground(this.update()); |
|
||||||
} |
|
||||||
|
|
||||||
} |
} |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 522 B |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 403 B |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.1 KiB |
@ -1,33 +1,33 @@ |
|||||||
package com.fr.design.mainframe.backgroundpane; |
package com.fr.design.mainframe.backgroundpane; |
||||||
|
|
||||||
import com.fr.design.beans.BasicBeanPane; |
import com.fr.design.beans.BasicBeanPane; |
||||||
import com.fr.design.event.UIObserver; |
import com.fr.design.event.UIObserver; |
||||||
import com.fr.general.Background; |
import com.fr.general.Background; |
||||||
|
|
||||||
/** |
/** |
||||||
* @author zhou |
* @author zhou |
||||||
* @since 2012-5-29下午1:12:28 |
* @since 2012-5-29下午1:12:28 |
||||||
*/ |
*/ |
||||||
public abstract class BackgroundSettingPane extends BasicBeanPane<Background> implements UIObserver { |
public abstract class BackgroundQuickPane extends BasicBeanPane<Background> implements UIObserver { |
||||||
|
|
||||||
public abstract boolean accept(Background background); |
public abstract boolean accept(Background background); |
||||||
|
|
||||||
@Override |
@Override |
||||||
public abstract void populateBean(Background background); |
public abstract void populateBean(Background background); |
||||||
|
|
||||||
@Override |
@Override |
||||||
public abstract Background updateBean(); |
public abstract Background updateBean(); |
||||||
|
|
||||||
@Override |
@Override |
||||||
public abstract String title4PopupWindow(); |
public abstract String title4PopupWindow(); |
||||||
|
|
||||||
/** |
/** |
||||||
* 组件是否需要响应添加的观察者事件 |
* 组件是否需要响应添加的观察者事件 |
||||||
* |
* |
||||||
* @return 如果需要响应观察者事件则返回true,否则返回false |
* @return 如果需要响应观察者事件则返回true,否则返回false |
||||||
*/ |
*/ |
||||||
public boolean shouldResponseChangeListener() { |
public boolean shouldResponseChangeListener() { |
||||||
|
|
||||||
return true; |
return true; |
||||||
} |
} |
||||||
} |
} |
@ -1,72 +1,72 @@ |
|||||||
package com.fr.design.mainframe.backgroundpane; |
package com.fr.design.mainframe.backgroundpane; |
||||||
|
|
||||||
import com.fr.base.background.ColorBackground; |
import com.fr.base.background.ColorBackground; |
||||||
import com.fr.design.event.UIObserverListener; |
import com.fr.design.event.UIObserverListener; |
||||||
import com.fr.design.layout.FRGUIPaneFactory; |
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
import com.fr.general.Background; |
import com.fr.general.Background; |
||||||
import com.fr.general.Inter; |
import com.fr.general.Inter; |
||||||
import com.fr.design.style.color.NewColorSelectPane; |
import com.fr.design.style.color.NewColorSelectPane; |
||||||
|
|
||||||
import javax.swing.event.ChangeEvent; |
import javax.swing.event.ChangeEvent; |
||||||
import javax.swing.event.ChangeListener; |
import javax.swing.event.ChangeListener; |
||||||
import java.awt.*; |
import java.awt.*; |
||||||
|
|
||||||
/** |
/** |
||||||
* @author zhou |
* @author zhou |
||||||
* @since 2012-5-29下午1:12:14 |
* @since 2012-5-29下午1:12:14 |
||||||
*/ |
*/ |
||||||
public class ColorBackgroundPane extends BackgroundSettingPane { |
public class ColorBackgroundQuickPane extends BackgroundQuickPane { |
||||||
|
|
||||||
private NewColorSelectPane detailColorSelectPane; |
private NewColorSelectPane detailColorSelectPane; |
||||||
|
|
||||||
public ColorBackgroundPane() { |
public ColorBackgroundQuickPane() { |
||||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
|
||||||
detailColorSelectPane = new NewColorSelectPane(); |
detailColorSelectPane = new NewColorSelectPane(); |
||||||
this.add(detailColorSelectPane, BorderLayout.NORTH); |
this.add(detailColorSelectPane, BorderLayout.NORTH); |
||||||
} |
} |
||||||
|
|
||||||
public void populateBean(Background background) { |
public void populateBean(Background background) { |
||||||
ColorBackground colorBackgroud = (ColorBackground) background; |
ColorBackground colorBackgroud = (ColorBackground) background; |
||||||
this.detailColorSelectPane.setColor(colorBackgroud.getColor()); |
this.detailColorSelectPane.setColor(colorBackgroud.getColor()); |
||||||
} |
} |
||||||
|
|
||||||
public Background updateBean() { |
public Background updateBean() { |
||||||
this.detailColorSelectPane.updateUsedColor(); |
this.detailColorSelectPane.updateUsedColor(); |
||||||
return ColorBackground.getInstance(this.detailColorSelectPane.getNotNoneColor()); |
return ColorBackground.getInstance(this.detailColorSelectPane.getNotNoneColor()); |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 给组件登记一个观察者监听事件 |
* 给组件登记一个观察者监听事件 |
||||||
* |
* |
||||||
* @param listener 观察者监听事件 |
* @param listener 观察者监听事件 |
||||||
*/ |
*/ |
||||||
public void registerChangeListener(final UIObserverListener listener) { |
public void registerChangeListener(final UIObserverListener listener) { |
||||||
detailColorSelectPane.addChangeListener(new ChangeListener() { |
detailColorSelectPane.addChangeListener(new ChangeListener() { |
||||||
public void stateChanged(ChangeEvent e) { |
public void stateChanged(ChangeEvent e) { |
||||||
listener.doChange(); |
listener.doChange(); |
||||||
} |
} |
||||||
}); |
}); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
/** |
/** |
||||||
* 是否为ColorBackground 类型 |
* 是否为ColorBackground 类型 |
||||||
* |
* |
||||||
* @param background 背景 |
* @param background 背景 |
||||||
* @return 同上 |
* @return 同上 |
||||||
* |
* |
||||||
*/ |
*/ |
||||||
public boolean accept(Background background) { |
public boolean accept(Background background) { |
||||||
return background instanceof ColorBackground; |
return background instanceof ColorBackground; |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
/** |
/** |
||||||
* 窗口名称 |
* 窗口名称 |
||||||
* @return 同上 |
* @return 同上 |
||||||
*/ |
*/ |
||||||
public String title4PopupWindow() { |
public String title4PopupWindow() { |
||||||
return Inter.getLocText("Color"); |
return Inter.getLocText("Color"); |
||||||
} |
} |
||||||
} |
} |
@ -1,123 +1,122 @@ |
|||||||
package com.fr.design.gui.style; |
package com.fr.design.mainframe.backgroundpane; |
||||||
|
|
||||||
import com.fr.base.background.GradientBackground; |
import com.fr.base.background.GradientBackground; |
||||||
import com.fr.design.event.UIObserverListener; |
import com.fr.design.event.UIObserverListener; |
||||||
import com.fr.design.gui.ibutton.UIButtonGroup; |
import com.fr.design.gui.ibutton.UIButtonGroup; |
||||||
import com.fr.design.gui.ilable.UILabel; |
import com.fr.design.gui.ilable.UILabel; |
||||||
import com.fr.design.layout.TableLayout; |
import com.fr.design.layout.TableLayout; |
||||||
import com.fr.design.layout.TableLayoutHelper; |
import com.fr.design.layout.TableLayoutHelper; |
||||||
import com.fr.design.mainframe.backgroundpane.BackgroundSettingPane; |
import com.fr.design.style.background.gradient.GradientBar; |
||||||
import com.fr.general.Background; |
import com.fr.general.Background; |
||||||
import com.fr.general.Inter; |
import com.fr.general.Inter; |
||||||
import com.fr.design.style.background.gradient.GradientBar; |
|
||||||
|
import javax.swing.*; |
||||||
import javax.swing.*; |
import javax.swing.event.ChangeEvent; |
||||||
import javax.swing.event.ChangeEvent; |
import javax.swing.event.ChangeListener; |
||||||
import javax.swing.event.ChangeListener; |
import java.awt.*; |
||||||
import java.awt.*; |
|
||||||
|
/** |
||||||
/** |
* @author zhou |
||||||
* @author zhou |
* @since 2012-5-30上午10:36:21 |
||||||
* @since 2012-5-30上午10:36:21 |
*/ |
||||||
*/ |
public class GradientBackgroundQuickPane extends BackgroundQuickPane { |
||||||
public class GradientPane extends BackgroundSettingPane { |
private static final long serialVersionUID = -6854603990673031897L; |
||||||
private static final long serialVersionUID = -6854603990673031897L; |
|
||||||
|
private static final int DEFAULT_GRADIENT_WIDTH = 185; |
||||||
private static final int DEFAULT_GRADIENT_WIDTH = 185; |
|
||||||
|
private int gradientBarWidth = DEFAULT_GRADIENT_WIDTH; |
||||||
private int gradientBarWidth = DEFAULT_GRADIENT_WIDTH; |
|
||||||
|
private GradientBar gradientBar; |
||||||
private GradientBar gradientBar; |
private UIButtonGroup<Integer> directionPane; |
||||||
private UIButtonGroup<Integer> directionPane; |
|
||||||
|
public GradientBackgroundQuickPane() { |
||||||
public GradientPane() { |
constructPane(); |
||||||
constructPane(); |
} |
||||||
} |
|
||||||
|
public GradientBackgroundQuickPane(int gradientBarWidth) { |
||||||
public GradientPane(int gradientBarWidth) { |
this.gradientBarWidth = gradientBarWidth; |
||||||
this.gradientBarWidth = gradientBarWidth; |
constructPane(); |
||||||
constructPane(); |
} |
||||||
} |
|
||||||
|
private void constructPane(){ |
||||||
private void constructPane(){ |
String[] textArray = {Inter.getLocText("Utils-Left_to_Right"), Inter.getLocText("Utils-Top_to_Bottom")}; |
||||||
String[] textArray = {Inter.getLocText("Utils-Left_to_Right"), Inter.getLocText("Utils-Top_to_Bottom")}; |
Integer[] valueArray = {GradientBackground.LEFT2RIGHT, GradientBackground.TOP2BOTTOM}; |
||||||
Integer[] valueArray = {GradientBackground.LEFT2RIGHT, GradientBackground.TOP2BOTTOM}; |
directionPane = new UIButtonGroup<Integer>(textArray, valueArray); |
||||||
directionPane = new UIButtonGroup<Integer>(textArray, valueArray); |
directionPane.setSelectedIndex(0); |
||||||
directionPane.setSelectedIndex(0); |
gradientBar = new GradientBar(4, this.gradientBarWidth); |
||||||
gradientBar = new GradientBar(4, this.gradientBarWidth); |
|
||||||
|
double p = TableLayout.PREFERRED; |
||||||
double p = TableLayout.PREFERRED; |
double f = TableLayout.FILL; |
||||||
double f = TableLayout.FILL; |
double[] columnSize = {p, f}; |
||||||
double[] columnSize = {p, f}; |
double[] rowSize = {p, p,}; |
||||||
double[] rowSize = {p, p,}; |
|
||||||
|
Component[][] components = new Component[][]{ |
||||||
Component[][] components = new Component[][]{ |
new Component[]{gradientBar, null}, |
||||||
new Component[]{gradientBar, null}, |
new Component[]{new UILabel(Inter.getLocText("Gradient-Direction") + ":"), directionPane} |
||||||
new Component[]{new UILabel(Inter.getLocText("Gradient-Direction") + ":"), directionPane} |
}; |
||||||
}; |
JPanel Gradient = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
||||||
JPanel Gradient = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
this.setLayout(new BorderLayout()); |
||||||
this.setLayout(new BorderLayout()); |
this.add(Gradient, BorderLayout.CENTER); |
||||||
this.add(Gradient, BorderLayout.CENTER); |
} |
||||||
} |
|
||||||
|
public void populateBean(Background background) { |
||||||
public void populateBean(Background background) { |
GradientBackground bg = (GradientBackground) background; |
||||||
GradientBackground bg = (GradientBackground) background; |
this.gradientBar.getSelectColorPointBtnP1().setColorInner(bg.getStartColor()); |
||||||
this.gradientBar.getSelectColorPointBtnP1().setColorInner(bg.getStartColor()); |
this.gradientBar.getSelectColorPointBtnP2().setColorInner(bg.getEndColor()); |
||||||
this.gradientBar.getSelectColorPointBtnP2().setColorInner(bg.getEndColor()); |
directionPane.setSelectedItem(bg.getDirection()); |
||||||
directionPane.setSelectedItem(bg.getDirection()); |
if (bg.isUseCell()) { |
||||||
if (bg.isUseCell()) { |
return; |
||||||
return; |
} |
||||||
} |
double startValue = (double) bg.getBeginPlace(); |
||||||
double startValue = (double) bg.getBeginPlace(); |
double endValue = (double) bg.getFinishPlace(); |
||||||
double endValue = (double) bg.getFinishPlace(); |
gradientBar.setStartValue(startValue); |
||||||
gradientBar.setStartValue(startValue); |
gradientBar.setEndValue(endValue); |
||||||
gradientBar.setEndValue(endValue); |
if(this.gradientBar.getSelectColorPointBtnP1() != null && this.gradientBar.getSelectColorPointBtnP2() != null){ |
||||||
if(this.gradientBar.getSelectColorPointBtnP1() != null && this.gradientBar.getSelectColorPointBtnP2() != null){ |
this.gradientBar.getSelectColorPointBtnP1().setX(startValue); |
||||||
this.gradientBar.getSelectColorPointBtnP1().setX(startValue); |
this.gradientBar.getSelectColorPointBtnP2().setX(endValue); |
||||||
this.gradientBar.getSelectColorPointBtnP2().setX(endValue); |
} |
||||||
} |
this.gradientBar.repaint(); |
||||||
this.gradientBar.repaint(); |
} |
||||||
} |
|
||||||
|
public GradientBackground updateBean() { |
||||||
public GradientBackground updateBean() { |
GradientBackground gb = new GradientBackground(gradientBar.getSelectColorPointBtnP1().getColorInner(), gradientBar.getSelectColorPointBtnP2().getColorInner()); |
||||||
GradientBackground gb = new GradientBackground(gradientBar.getSelectColorPointBtnP1().getColorInner(), gradientBar.getSelectColorPointBtnP2().getColorInner()); |
gb.setDirection(directionPane.getSelectedItem()); |
||||||
gb.setDirection(directionPane.getSelectedItem()); |
if (gradientBar.isOriginalPlace()) { |
||||||
if (gradientBar.isOriginalPlace()) { |
gb.setUseCell(true); |
||||||
gb.setUseCell(true); |
} else { |
||||||
} else { |
gb.setUseCell(false); |
||||||
gb.setUseCell(false); |
gb.setBeginPlace((float) gradientBar.getStartValue()); |
||||||
gb.setBeginPlace((float) gradientBar.getStartValue()); |
gb.setFinishPlace((float) gradientBar.getEndValue()); |
||||||
gb.setFinishPlace((float) gradientBar.getEndValue()); |
} |
||||||
} |
return gb; |
||||||
return gb; |
} |
||||||
} |
|
||||||
|
/** |
||||||
/** |
* 给组件登记一个观察者监听事件 |
||||||
* 给组件登记一个观察者监听事件 |
* |
||||||
* |
* @param listener 观察者监听事件 |
||||||
* @param listener 观察者监听事件 |
*/ |
||||||
*/ |
public void registerChangeListener(final UIObserverListener listener) { |
||||||
public void registerChangeListener(final UIObserverListener listener) { |
gradientBar.addChangeListener(new ChangeListener() { |
||||||
gradientBar.addChangeListener(new ChangeListener() { |
public void stateChanged(ChangeEvent e) { |
||||||
public void stateChanged(ChangeEvent e) { |
listener.doChange(); |
||||||
listener.doChange(); |
} |
||||||
} |
}); |
||||||
}); |
directionPane.addChangeListener(new ChangeListener() { |
||||||
directionPane.addChangeListener(new ChangeListener() { |
public void stateChanged(ChangeEvent e) { |
||||||
public void stateChanged(ChangeEvent e) { |
listener.doChange(); |
||||||
listener.doChange(); |
} |
||||||
} |
}); |
||||||
}); |
} |
||||||
} |
|
||||||
|
@Override |
||||||
@Override |
public boolean accept(Background background) { |
||||||
public boolean accept(Background background) { |
return background instanceof GradientBackground; |
||||||
return background instanceof GradientBackground; |
} |
||||||
} |
|
||||||
|
@Override |
||||||
@Override |
public String title4PopupWindow() { |
||||||
public String title4PopupWindow() { |
return Inter.getLocText("Gradient-Color"); |
||||||
return Inter.getLocText("Gradient-Color"); |
} |
||||||
} |
|
||||||
|
|
||||||
} |
} |
@ -1,185 +1,185 @@ |
|||||||
package com.fr.design.mainframe.backgroundpane; |
package com.fr.design.mainframe.backgroundpane; |
||||||
|
|
||||||
import com.fr.base.BaseUtils; |
import com.fr.base.BaseUtils; |
||||||
import com.fr.base.Style; |
import com.fr.base.Style; |
||||||
import com.fr.base.background.ImageBackground; |
import com.fr.base.background.ImageBackground; |
||||||
import com.fr.design.constants.UIConstants; |
import com.fr.design.constants.UIConstants; |
||||||
import com.fr.design.border.UIRoundedBorder; |
import com.fr.design.border.UIRoundedBorder; |
||||||
import com.fr.design.event.UIObserverListener; |
import com.fr.design.event.UIObserverListener; |
||||||
import com.fr.design.gui.ibutton.UIButton; |
import com.fr.design.gui.ibutton.UIButton; |
||||||
import com.fr.design.gui.ibutton.UIButtonGroup; |
import com.fr.design.gui.ibutton.UIButtonGroup; |
||||||
import com.fr.design.layout.FRGUIPaneFactory; |
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
import com.fr.design.mainframe.DesignerContext; |
import com.fr.design.mainframe.DesignerContext; |
||||||
import com.fr.general.Background; |
import com.fr.general.Background; |
||||||
import com.fr.general.Inter; |
import com.fr.general.Inter; |
||||||
import com.fr.stable.Constants; |
import com.fr.stable.Constants; |
||||||
import com.fr.stable.CoreGraphHelper; |
import com.fr.stable.CoreGraphHelper; |
||||||
import com.fr.design.style.background.image.ImageFileChooser; |
import com.fr.design.style.background.image.ImageFileChooser; |
||||||
|
|
||||||
import javax.swing.*; |
import javax.swing.*; |
||||||
import javax.swing.event.ChangeEvent; |
import javax.swing.event.ChangeEvent; |
||||||
import javax.swing.event.ChangeListener; |
import javax.swing.event.ChangeListener; |
||||||
import java.awt.*; |
import java.awt.*; |
||||||
import java.awt.event.ActionEvent; |
import java.awt.event.ActionEvent; |
||||||
import java.awt.event.ActionListener; |
import java.awt.event.ActionListener; |
||||||
import java.io.File; |
import java.io.File; |
||||||
|
|
||||||
/** |
/** |
||||||
* @author zhou |
* @author zhou |
||||||
* @since 2012-5-29下午1:12:06 |
* @since 2012-5-29下午1:12:06 |
||||||
*/ |
*/ |
||||||
public class ImageBackgroundPane extends BackgroundSettingPane { |
public class ImageBackgroundQuickPane extends BackgroundQuickPane { |
||||||
|
|
||||||
private ImagePreviewPane previewPane; |
private ImagePreviewPane previewPane; |
||||||
private Style imageStyle = null; |
private Style imageStyle = null; |
||||||
private ChangeListener changeListener = null; |
private ChangeListener changeListener = null; |
||||||
private ImageFileChooser imageFileChooser; |
private ImageFileChooser imageFileChooser; |
||||||
|
|
||||||
private UIButtonGroup<Byte> imageLayoutPane; |
private UIButtonGroup<Byte> imageLayoutPane; |
||||||
|
|
||||||
public ImageBackgroundPane() { |
public ImageBackgroundQuickPane() { |
||||||
this(true); |
this(true); |
||||||
} |
} |
||||||
|
|
||||||
public ImageBackgroundPane(boolean hasImageLayout) { |
public ImageBackgroundQuickPane(boolean hasImageLayout) { |
||||||
this.setLayout(new BorderLayout(0, 4)); |
this.setLayout(new BorderLayout(0, 4)); |
||||||
String[] nameArray = {Inter.getLocText("FR-Background_Image_Default"), Inter.getLocText("FR-Background_Image_Titled"), Inter.getLocText("FR-Background_Image_Adjust"), Inter.getLocText("FR-Background_Image_Extend")}; |
String[] nameArray = {Inter.getLocText("FR-Background_Image_Default"), Inter.getLocText("FR-Background_Image_Titled"), Inter.getLocText("FR-Background_Image_Adjust"), Inter.getLocText("FR-Background_Image_Extend")}; |
||||||
Byte[] valueArray = {Constants.IMAGE_CENTER, Constants.IMAGE_TILED, Constants.IMAGE_EXTEND, Constants.IMAGE_ADJUST}; |
Byte[] valueArray = {Constants.IMAGE_CENTER, Constants.IMAGE_TILED, Constants.IMAGE_EXTEND, Constants.IMAGE_ADJUST}; |
||||||
imageLayoutPane = new UIButtonGroup<Byte>(nameArray, valueArray); |
imageLayoutPane = new UIButtonGroup<Byte>(nameArray, valueArray); |
||||||
imageLayoutPane.setSelectedIndex(0); |
imageLayoutPane.setSelectedIndex(0); |
||||||
|
|
||||||
previewPane = new ImagePreviewPane(); |
previewPane = new ImagePreviewPane(); |
||||||
JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
borderPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5)); |
borderPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5)); |
||||||
borderPane.setPreferredSize(new Dimension(0, 145)); |
borderPane.setPreferredSize(new Dimension(0, 145)); |
||||||
borderPane.add(previewPane, BorderLayout.CENTER); |
borderPane.add(previewPane, BorderLayout.CENTER); |
||||||
this.add(borderPane, BorderLayout.NORTH); |
this.add(borderPane, BorderLayout.NORTH); |
||||||
previewPane.addChangeListener(imageSizeChangeListener); |
previewPane.addChangeListener(imageSizeChangeListener); |
||||||
|
|
||||||
JPanel southPane = new JPanel(new BorderLayout(0, 4)); |
JPanel southPane = new JPanel(new BorderLayout(0, 4)); |
||||||
JPanel contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
JPanel contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
contentPane.add(southPane, BorderLayout.NORTH); |
contentPane.add(southPane, BorderLayout.NORTH); |
||||||
this.add(contentPane, BorderLayout.CENTER); |
this.add(contentPane, BorderLayout.CENTER); |
||||||
|
|
||||||
JPanel selectFilePane = new JPanel(new GridLayout(0, 2)); |
JPanel selectFilePane = new JPanel(new GridLayout(0, 2)); |
||||||
|
|
||||||
UIButton selectPictureButton = new UIButton(Inter.getLocText("Image-Select_Picture")); |
UIButton selectPictureButton = new UIButton(Inter.getLocText("Image-Select_Picture")); |
||||||
selectFilePane.add(new JPanel()); |
selectFilePane.add(new JPanel()); |
||||||
selectFilePane.add(selectPictureButton); |
selectFilePane.add(selectPictureButton); |
||||||
selectPictureButton.addActionListener(selectPictureActionListener); |
selectPictureButton.addActionListener(selectPictureActionListener); |
||||||
|
|
||||||
if(hasImageLayout){ |
if(hasImageLayout){ |
||||||
southPane.add(imageLayoutPane, BorderLayout.CENTER); |
southPane.add(imageLayoutPane, BorderLayout.CENTER); |
||||||
} |
} |
||||||
southPane.add(selectFilePane, BorderLayout.SOUTH); |
southPane.add(selectFilePane, BorderLayout.SOUTH); |
||||||
|
|
||||||
imageLayoutPane.addChangeListener(new ChangeListener() { |
imageLayoutPane.addChangeListener(new ChangeListener() { |
||||||
|
|
||||||
@Override |
@Override |
||||||
public void stateChanged(ChangeEvent e) { |
public void stateChanged(ChangeEvent e) { |
||||||
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(imageLayoutPane.getSelectedItem()); |
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(imageLayoutPane.getSelectedItem()); |
||||||
previewPane.setImageStyle(imageStyle); |
previewPane.setImageStyle(imageStyle); |
||||||
previewPane.repaint(); |
previewPane.repaint(); |
||||||
} |
} |
||||||
}); |
}); |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* Select picture. |
* Select picture. |
||||||
*/ |
*/ |
||||||
ActionListener selectPictureActionListener = new ActionListener() { |
ActionListener selectPictureActionListener = new ActionListener() { |
||||||
|
|
||||||
public void actionPerformed(ActionEvent evt) { |
public void actionPerformed(ActionEvent evt) { |
||||||
if (imageFileChooser == null) { |
if (imageFileChooser == null) { |
||||||
imageFileChooser = new ImageFileChooser(); |
imageFileChooser = new ImageFileChooser(); |
||||||
imageFileChooser.setMultiSelectionEnabled(false); |
imageFileChooser.setMultiSelectionEnabled(false); |
||||||
} |
} |
||||||
int returnVal = imageFileChooser.showOpenDialog(DesignerContext.getDesignerFrame()); |
int returnVal = imageFileChooser.showOpenDialog(DesignerContext.getDesignerFrame()); |
||||||
if (returnVal != JFileChooser.CANCEL_OPTION) { |
if (returnVal != JFileChooser.CANCEL_OPTION) { |
||||||
File selectedFile = imageFileChooser.getSelectedFile(); |
File selectedFile = imageFileChooser.getSelectedFile(); |
||||||
|
|
||||||
if (selectedFile != null && selectedFile.isFile()) { |
if (selectedFile != null && selectedFile.isFile()) { |
||||||
Image image = BaseUtils.readImage(selectedFile.getPath()); |
Image image = BaseUtils.readImage(selectedFile.getPath()); |
||||||
CoreGraphHelper.waitForImage(image); |
CoreGraphHelper.waitForImage(image); |
||||||
|
|
||||||
previewPane.setImage(image); |
previewPane.setImage(image); |
||||||
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(imageLayoutPane.getSelectedItem()); |
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(imageLayoutPane.getSelectedItem()); |
||||||
previewPane.setImageStyle(imageStyle); |
previewPane.setImageStyle(imageStyle); |
||||||
previewPane.repaint(); |
previewPane.repaint(); |
||||||
} else { |
} else { |
||||||
previewPane.setImage(null); |
previewPane.setImage(null); |
||||||
} |
} |
||||||
fireChagneListener(); |
fireChagneListener(); |
||||||
} |
} |
||||||
|
|
||||||
} |
} |
||||||
}; |
}; |
||||||
|
|
||||||
public void populateBean(Background background) { |
public void populateBean(Background background) { |
||||||
|
|
||||||
ImageBackground imageBackground = (ImageBackground) background; |
ImageBackground imageBackground = (ImageBackground) background; |
||||||
imageLayoutPane.setSelectedItem((byte) imageBackground.getLayout()); |
imageLayoutPane.setSelectedItem((byte) imageBackground.getLayout()); |
||||||
Style.DEFAULT_STYLE.deriveImageLayout(imageBackground.getLayout()); |
Style.DEFAULT_STYLE.deriveImageLayout(imageBackground.getLayout()); |
||||||
|
|
||||||
previewPane.setImageStyle(ImageBackgroundPane.this.imageStyle); |
previewPane.setImageStyle(ImageBackgroundQuickPane.this.imageStyle); |
||||||
previewPane.setImage(imageBackground.getImage()); |
previewPane.setImage(imageBackground.getImage()); |
||||||
previewPane.repaint(); |
previewPane.repaint(); |
||||||
} |
} |
||||||
|
|
||||||
public Background updateBean() { |
public Background updateBean() { |
||||||
ImageBackground imageBackground = new ImageBackground(previewPane.getImage()); |
ImageBackground imageBackground = new ImageBackground(previewPane.getImage()); |
||||||
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(imageLayoutPane.getSelectedItem()); |
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(imageLayoutPane.getSelectedItem()); |
||||||
imageBackground.setLayout(imageStyle.getImageLayout()); |
imageBackground.setLayout(imageStyle.getImageLayout()); |
||||||
return imageBackground; |
return imageBackground; |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 给组件登记一个观察者监听事件 |
* 给组件登记一个观察者监听事件 |
||||||
* |
* |
||||||
* @param listener 观察者监听事件 |
* @param listener 观察者监听事件 |
||||||
*/ |
*/ |
||||||
public void registerChangeListener(final UIObserverListener listener) { |
public void registerChangeListener(final UIObserverListener listener) { |
||||||
changeListener = new ChangeListener() { |
changeListener = new ChangeListener() { |
||||||
public void stateChanged(ChangeEvent e) { |
public void stateChanged(ChangeEvent e) { |
||||||
listener.doChange(); |
listener.doChange(); |
||||||
} |
} |
||||||
}; |
}; |
||||||
imageLayoutPane.addChangeListener(changeListener); |
imageLayoutPane.addChangeListener(changeListener); |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
private void fireChagneListener() { |
private void fireChagneListener() { |
||||||
if (this.changeListener != null) { |
if (this.changeListener != null) { |
||||||
ChangeEvent evt = new ChangeEvent(this); |
ChangeEvent evt = new ChangeEvent(this); |
||||||
this.changeListener.stateChanged(evt); |
this.changeListener.stateChanged(evt); |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
ChangeListener imageSizeChangeListener = new ChangeListener() { |
ChangeListener imageSizeChangeListener = new ChangeListener() { |
||||||
|
|
||||||
public void stateChanged(ChangeEvent evt) { |
public void stateChanged(ChangeEvent evt) { |
||||||
if (imageLayoutPane.getSelectedItem() != null) { |
if (imageLayoutPane.getSelectedItem() != null) { |
||||||
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(imageLayoutPane.getSelectedItem()); |
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(imageLayoutPane.getSelectedItem()); |
||||||
previewPane.setImageStyle(imageStyle); |
previewPane.setImageStyle(imageStyle); |
||||||
previewPane.repaint(); |
previewPane.repaint(); |
||||||
} |
} |
||||||
} |
} |
||||||
}; |
}; |
||||||
|
|
||||||
/** |
/** |
||||||
* 判断是否是图片背景 |
* 判断是否是图片背景 |
||||||
* @param background 背景 |
* @param background 背景 |
||||||
* @return 判断是否是图片背景 |
* @return 判断是否是图片背景 |
||||||
*/ |
*/ |
||||||
public boolean accept(Background background) { |
public boolean accept(Background background) { |
||||||
return background instanceof ImageBackground; |
return background instanceof ImageBackground; |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 标题 |
* 标题 |
||||||
* @return 标题 |
* @return 标题 |
||||||
*/ |
*/ |
||||||
public String title4PopupWindow() { |
public String title4PopupWindow() { |
||||||
return Inter.getLocText("FR-Background_Image"); |
return Inter.getLocText("FR-Background_Image"); |
||||||
} |
} |
||||||
} |
} |
@ -1,54 +1,54 @@ |
|||||||
package com.fr.design.mainframe.backgroundpane; |
package com.fr.design.mainframe.backgroundpane; |
||||||
|
|
||||||
import com.fr.design.event.UIObserverListener; |
import com.fr.design.event.UIObserverListener; |
||||||
import com.fr.general.Background; |
import com.fr.general.Background; |
||||||
import com.fr.general.Inter; |
import com.fr.general.Inter; |
||||||
|
|
||||||
import java.awt.*; |
import java.awt.*; |
||||||
|
|
||||||
/** |
/** |
||||||
* @author zhou |
* @author zhou |
||||||
* @since 2012-5-29下午1:12:24 |
* @since 2012-5-29下午1:12:24 |
||||||
*/ |
*/ |
||||||
public class NullBackgroundPane extends BackgroundSettingPane { |
public class NullBackgroundQuickPane extends BackgroundQuickPane { |
||||||
|
|
||||||
public Dimension getPreferredSize(){ |
public Dimension getPreferredSize(){ |
||||||
return new Dimension(0,0); |
return new Dimension(0,0); |
||||||
} |
} |
||||||
|
|
||||||
public void populateBean(Background background) { |
public void populateBean(Background background) { |
||||||
// do nothing.
|
// do nothing.
|
||||||
} |
} |
||||||
|
|
||||||
public Background updateBean() { |
public Background updateBean() { |
||||||
return null; |
return null; |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 给组件登记一个观察者监听事件 |
* 给组件登记一个观察者监听事件 |
||||||
* |
* |
||||||
* @param listener 观察者监听事件 |
* @param listener 观察者监听事件 |
||||||
*/ |
*/ |
||||||
public void registerChangeListener(final UIObserverListener listener) { |
public void registerChangeListener(final UIObserverListener listener) { |
||||||
|
|
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
/** |
/** |
||||||
* 是否接受 |
* 是否接受 |
||||||
* @param background 背景 |
* @param background 背景 |
||||||
* @return 是则返回true |
* @return 是则返回true |
||||||
*/ |
*/ |
||||||
public boolean accept(Background background) { |
public boolean accept(Background background) { |
||||||
return background == null; |
return background == null; |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 名称 |
* 名称 |
||||||
* @return 名称 |
* @return 名称 |
||||||
*/ |
*/ |
||||||
public String title4PopupWindow() { |
public String title4PopupWindow() { |
||||||
return Inter.getLocText("Background-Null"); |
return Inter.getLocText("Background-Null"); |
||||||
} |
} |
||||||
|
|
||||||
} |
} |
@ -1,211 +1,211 @@ |
|||||||
package com.fr.design.mainframe.backgroundpane; |
package com.fr.design.mainframe.backgroundpane; |
||||||
|
|
||||||
import com.fr.base.GraphHelper; |
import com.fr.base.GraphHelper; |
||||||
import com.fr.base.background.PatternBackground; |
import com.fr.base.background.PatternBackground; |
||||||
import com.fr.design.constants.UIConstants; |
import com.fr.design.constants.UIConstants; |
||||||
import com.fr.design.border.UIRoundedBorder; |
import com.fr.design.border.UIRoundedBorder; |
||||||
import com.fr.design.event.UIObserverListener; |
import com.fr.design.event.UIObserverListener; |
||||||
import com.fr.design.gui.ilable.UILabel; |
import com.fr.design.gui.ilable.UILabel; |
||||||
import com.fr.design.layout.FRGUIPaneFactory; |
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
import com.fr.general.Background; |
import com.fr.general.Background; |
||||||
import com.fr.general.Inter; |
import com.fr.general.Inter; |
||||||
import com.fr.design.style.color.ColorSelectBox; |
import com.fr.design.style.color.ColorSelectBox; |
||||||
|
|
||||||
import javax.swing.*; |
import javax.swing.*; |
||||||
import javax.swing.event.ChangeEvent; |
import javax.swing.event.ChangeEvent; |
||||||
import javax.swing.event.ChangeListener; |
import javax.swing.event.ChangeListener; |
||||||
import java.awt.*; |
import java.awt.*; |
||||||
import java.awt.event.ActionEvent; |
import java.awt.event.ActionEvent; |
||||||
import java.awt.event.ActionListener; |
import java.awt.event.ActionListener; |
||||||
import java.awt.geom.Rectangle2D; |
import java.awt.geom.Rectangle2D; |
||||||
|
|
||||||
/** |
/** |
||||||
* @author zhou |
* @author zhou |
||||||
* @since 2012-5-29下午1:12:33 |
* @since 2012-5-29下午1:12:33 |
||||||
*/ |
*/ |
||||||
public class PatternBackgroundPane extends BackgroundSettingPane { |
public class PatternBackgroundQuickPane extends BackgroundQuickPane { |
||||||
|
|
||||||
private int patternIndex = 0; // pattern index.
|
private int patternIndex = 0; // pattern setIndex.
|
||||||
private ColorSelectBox foregroundColorPane; |
private ColorSelectBox foregroundColorPane; |
||||||
private ColorSelectBox backgroundColorPane; |
private ColorSelectBox backgroundColorPane; |
||||||
private PatternButton[] patternButtonArray; |
private PatternButton[] patternButtonArray; |
||||||
|
|
||||||
public PatternBackgroundPane() { |
public PatternBackgroundQuickPane() { |
||||||
this.setLayout(new BorderLayout(0, 4)); |
this.setLayout(new BorderLayout(0, 4)); |
||||||
|
|
||||||
JPanel contentPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); |
JPanel contentPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); |
||||||
this.add(contentPane, BorderLayout.NORTH); |
this.add(contentPane, BorderLayout.NORTH); |
||||||
contentPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5)); |
contentPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5)); |
||||||
|
|
||||||
JPanel typePane2 = new JPanel(); |
JPanel typePane2 = new JPanel(); |
||||||
contentPane.add(typePane2); |
contentPane.add(typePane2); |
||||||
typePane2.setLayout(new GridLayout(0, 8, 1, 1)); |
typePane2.setLayout(new GridLayout(0, 8, 1, 1)); |
||||||
typePane2.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); |
typePane2.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); |
||||||
ButtonGroup patternButtonGroup = new ButtonGroup(); |
ButtonGroup patternButtonGroup = new ButtonGroup(); |
||||||
patternButtonArray = new PatternButton[PatternBackground.PATTERN_COUNT]; |
patternButtonArray = new PatternButton[PatternBackground.PATTERN_COUNT]; |
||||||
for (int i = 0; i < PatternBackground.PATTERN_COUNT; i++) { |
for (int i = 0; i < PatternBackground.PATTERN_COUNT; i++) { |
||||||
patternButtonArray[i] = new PatternButton(i); |
patternButtonArray[i] = new PatternButton(i); |
||||||
patternButtonGroup.add(patternButtonArray[i]); |
patternButtonGroup.add(patternButtonArray[i]); |
||||||
typePane2.add(patternButtonArray[i]); |
typePane2.add(patternButtonArray[i]); |
||||||
} |
} |
||||||
|
|
||||||
JPanel colorPane = new JPanel(new GridLayout(0, 2)); |
JPanel colorPane = new JPanel(new GridLayout(0, 2)); |
||||||
foregroundColorPane = new ColorSelectBox(70); |
foregroundColorPane = new ColorSelectBox(70); |
||||||
backgroundColorPane = new ColorSelectBox(70); |
backgroundColorPane = new ColorSelectBox(70); |
||||||
foregroundColorPane.setSelectObject(Color.lightGray); |
foregroundColorPane.setSelectObject(Color.lightGray); |
||||||
backgroundColorPane.setSelectObject(Color.black); |
backgroundColorPane.setSelectObject(Color.black); |
||||||
|
|
||||||
colorPane.add(this.createLabelColorPane(Inter.getLocText("Foreground") + ":", foregroundColorPane)); |
colorPane.add(this.createLabelColorPane(Inter.getLocText("Foreground") + ":", foregroundColorPane)); |
||||||
colorPane.add(this.createLabelColorPane(Inter.getLocText("Background") + ":", backgroundColorPane)); |
colorPane.add(this.createLabelColorPane(Inter.getLocText("Background") + ":", backgroundColorPane)); |
||||||
this.add(colorPane, BorderLayout.CENTER); |
this.add(colorPane, BorderLayout.CENTER); |
||||||
foregroundColorPane.addSelectChangeListener(colorChangeListener); |
foregroundColorPane.addSelectChangeListener(colorChangeListener); |
||||||
backgroundColorPane.addSelectChangeListener(colorChangeListener); |
backgroundColorPane.addSelectChangeListener(colorChangeListener); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public Dimension getPreferredSize() { |
public Dimension getPreferredSize() { |
||||||
Dimension dim = super.getPreferredSize(); |
Dimension dim = super.getPreferredSize(); |
||||||
dim.height = 190; |
dim.height = 190; |
||||||
return dim; |
return dim; |
||||||
} |
} |
||||||
|
|
||||||
private JPanel createLabelColorPane(String text, JComponent colorPane) { |
private JPanel createLabelColorPane(String text, JComponent colorPane) { |
||||||
JPanel labelColorPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); |
JPanel labelColorPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); |
||||||
labelColorPane.add(new UILabel(text)); |
labelColorPane.add(new UILabel(text)); |
||||||
labelColorPane.add(colorPane); |
labelColorPane.add(colorPane); |
||||||
|
|
||||||
return labelColorPane; |
return labelColorPane; |
||||||
} |
} |
||||||
|
|
||||||
public void populateBean(Background background) { |
public void populateBean(Background background) { |
||||||
PatternBackground patternBackground = (PatternBackground) background; |
PatternBackground patternBackground = (PatternBackground) background; |
||||||
int patternIndex = patternBackground.getPatternIndex(); |
int patternIndex = patternBackground.getPatternIndex(); |
||||||
|
|
||||||
if (patternIndex >= 0 && patternIndex < this.patternButtonArray.length) { |
if (patternIndex >= 0 && patternIndex < this.patternButtonArray.length) { |
||||||
this.patternButtonArray[patternIndex].setSelected(true); |
this.patternButtonArray[patternIndex].setSelected(true); |
||||||
this.patternIndex = patternIndex; |
this.patternIndex = patternIndex; |
||||||
} else { |
} else { |
||||||
this.patternIndex = 0; |
this.patternIndex = 0; |
||||||
} |
} |
||||||
|
|
||||||
foregroundColorPane.setSelectObject(patternBackground.getForeground()); |
foregroundColorPane.setSelectObject(patternBackground.getForeground()); |
||||||
backgroundColorPane.setSelectObject(patternBackground.getBackground()); |
backgroundColorPane.setSelectObject(patternBackground.getBackground()); |
||||||
} |
} |
||||||
|
|
||||||
public Background updateBean() { |
public Background updateBean() { |
||||||
return new PatternBackground(patternIndex, foregroundColorPane.getSelectObject(), backgroundColorPane.getSelectObject()); |
return new PatternBackground(patternIndex, foregroundColorPane.getSelectObject(), backgroundColorPane.getSelectObject()); |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
/** |
/** |
||||||
* 给组件登记一个观察者监听事件 |
* 给组件登记一个观察者监听事件 |
||||||
* |
* |
||||||
* @param listener 观察者监听事件 |
* @param listener 观察者监听事件 |
||||||
*/ |
*/ |
||||||
public void registerChangeListener(final UIObserverListener listener) { |
public void registerChangeListener(final UIObserverListener listener) { |
||||||
foregroundColorPane.addSelectChangeListener(new ChangeListener() { |
foregroundColorPane.addSelectChangeListener(new ChangeListener() { |
||||||
public void stateChanged(ChangeEvent e) { |
public void stateChanged(ChangeEvent e) { |
||||||
listener.doChange(); |
listener.doChange(); |
||||||
} |
} |
||||||
}); |
}); |
||||||
backgroundColorPane.addSelectChangeListener(new ChangeListener() { |
backgroundColorPane.addSelectChangeListener(new ChangeListener() { |
||||||
public void stateChanged(ChangeEvent e) { |
public void stateChanged(ChangeEvent e) { |
||||||
listener.doChange(); |
listener.doChange(); |
||||||
} |
} |
||||||
}); |
}); |
||||||
for (int i = 0, count = patternButtonArray.length; i < count; i ++) { |
for (int i = 0, count = patternButtonArray.length; i < count; i ++) { |
||||||
patternButtonArray[i].addChangeListener(new ChangeListener() { |
patternButtonArray[i].addChangeListener(new ChangeListener() { |
||||||
public void stateChanged(ChangeEvent e) { |
public void stateChanged(ChangeEvent e) { |
||||||
listener.doChange(); |
listener.doChange(); |
||||||
} |
} |
||||||
}); |
}); |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
// Foreground or Background changed.
|
// Foreground or Background changed.
|
||||||
ChangeListener colorChangeListener = new ChangeListener() { |
ChangeListener colorChangeListener = new ChangeListener() { |
||||||
|
|
||||||
public void stateChanged(ChangeEvent e) { |
public void stateChanged(ChangeEvent e) { |
||||||
for (int i = 0; i < patternButtonArray.length; i++) { |
for (int i = 0; i < patternButtonArray.length; i++) { |
||||||
patternButtonArray[i].setPatternForeground(foregroundColorPane.getSelectObject()); |
patternButtonArray[i].setPatternForeground(foregroundColorPane.getSelectObject()); |
||||||
patternButtonArray[i].setPatternBackground(backgroundColorPane.getSelectObject()); |
patternButtonArray[i].setPatternBackground(backgroundColorPane.getSelectObject()); |
||||||
} |
} |
||||||
|
|
||||||
PatternBackgroundPane.this.repaint();// repaint
|
PatternBackgroundQuickPane.this.repaint();// repaint
|
||||||
} |
} |
||||||
}; |
}; |
||||||
|
|
||||||
/** |
/** |
||||||
* Pattern type button. |
* Pattern type button. |
||||||
*/ |
*/ |
||||||
class PatternButton extends JToggleButton implements ActionListener { |
class PatternButton extends JToggleButton implements ActionListener { |
||||||
|
|
||||||
public PatternButton(int pIndex) { |
public PatternButton(int pIndex) { |
||||||
this.pIndex = pIndex; |
this.pIndex = pIndex; |
||||||
this.addActionListener(this); |
this.addActionListener(this); |
||||||
|
|
||||||
this.setCursor(new Cursor(Cursor.HAND_CURSOR)); |
this.setCursor(new Cursor(Cursor.HAND_CURSOR)); |
||||||
this.setBorder(null); |
this.setBorder(null); |
||||||
this.patternBackground = new PatternBackground(this.pIndex, Color.lightGray, Color.black); |
this.patternBackground = new PatternBackground(this.pIndex, Color.lightGray, Color.black); |
||||||
} |
} |
||||||
|
|
||||||
public void paintComponent(Graphics g) { |
public void paintComponent(Graphics g) { |
||||||
Graphics2D g2d = (Graphics2D) g; |
Graphics2D g2d = (Graphics2D) g; |
||||||
|
|
||||||
Dimension d = getSize(); |
Dimension d = getSize(); |
||||||
this.patternBackground.paint(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); |
this.patternBackground.paint(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); |
||||||
|
|
||||||
if (this.pIndex == patternIndex) {// it's selected.
|
if (this.pIndex == patternIndex) {// it's selected.
|
||||||
g2d.setPaint(UIConstants.LINE_COLOR); |
g2d.setPaint(UIConstants.LINE_COLOR); |
||||||
GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); |
GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
public Dimension getPreferredSize() { |
public Dimension getPreferredSize() { |
||||||
return new Dimension(super.getPreferredSize().width, 20); |
return new Dimension(super.getPreferredSize().width, 20); |
||||||
} |
} |
||||||
|
|
||||||
public void setPatternForeground(Color foreground) { |
public void setPatternForeground(Color foreground) { |
||||||
this.patternBackground.setForeground(foreground); |
this.patternBackground.setForeground(foreground); |
||||||
} |
} |
||||||
|
|
||||||
public void setPatternBackground(Color background) { |
public void setPatternBackground(Color background) { |
||||||
this.patternBackground.setBackground(background); |
this.patternBackground.setBackground(background); |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* set Pattern index. |
* set Pattern setIndex. |
||||||
*/ |
*/ |
||||||
public void actionPerformed(ActionEvent evt) { |
public void actionPerformed(ActionEvent evt) { |
||||||
PatternBackgroundPane.this.patternIndex = pIndex; |
PatternBackgroundQuickPane.this.patternIndex = pIndex; |
||||||
|
|
||||||
fireChagneListener(); |
fireChagneListener(); |
||||||
PatternBackgroundPane.this.repaint();// repaint
|
PatternBackgroundQuickPane.this.repaint();// repaint
|
||||||
} |
} |
||||||
|
|
||||||
public void addChangeListener(ChangeListener changeListener) { |
public void addChangeListener(ChangeListener changeListener) { |
||||||
this.changeListener = changeListener; |
this.changeListener = changeListener; |
||||||
} |
} |
||||||
|
|
||||||
private void fireChagneListener() { |
private void fireChagneListener() { |
||||||
if (this.changeListener != null) { |
if (this.changeListener != null) { |
||||||
ChangeEvent evt = new ChangeEvent(this); |
ChangeEvent evt = new ChangeEvent(this); |
||||||
this.changeListener.stateChanged(evt); |
this.changeListener.stateChanged(evt); |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
private int pIndex = 0; |
private int pIndex = 0; |
||||||
private PatternBackground patternBackground; |
private PatternBackground patternBackground; |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public boolean accept(Background background) { |
public boolean accept(Background background) { |
||||||
return background instanceof PatternBackground; |
return background instanceof PatternBackground; |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public String title4PopupWindow() { |
public String title4PopupWindow() { |
||||||
return Inter.getLocText("Background-Pattern"); |
return Inter.getLocText("Background-Pattern"); |
||||||
} |
} |
||||||
} |
} |
@ -1,173 +1,173 @@ |
|||||||
package com.fr.design.mainframe.backgroundpane; |
package com.fr.design.mainframe.backgroundpane; |
||||||
|
|
||||||
import com.fr.base.GraphHelper; |
import com.fr.base.GraphHelper; |
||||||
import com.fr.base.background.TextureBackground; |
import com.fr.base.background.TextureBackground; |
||||||
import com.fr.design.constants.UIConstants; |
import com.fr.design.constants.UIConstants; |
||||||
import com.fr.design.border.UIRoundedBorder; |
import com.fr.design.border.UIRoundedBorder; |
||||||
import com.fr.design.event.UIObserverListener; |
import com.fr.design.event.UIObserverListener; |
||||||
import com.fr.design.layout.FRGUIPaneFactory; |
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
import com.fr.general.Background; |
import com.fr.general.Background; |
||||||
import com.fr.general.ComparatorUtils; |
import com.fr.general.ComparatorUtils; |
||||||
import com.fr.general.Inter; |
import com.fr.general.Inter; |
||||||
|
|
||||||
import javax.swing.*; |
import javax.swing.*; |
||||||
import javax.swing.event.ChangeEvent; |
import javax.swing.event.ChangeEvent; |
||||||
import javax.swing.event.ChangeListener; |
import javax.swing.event.ChangeListener; |
||||||
import java.awt.*; |
import java.awt.*; |
||||||
import java.awt.event.ActionEvent; |
import java.awt.event.ActionEvent; |
||||||
import java.awt.event.ActionListener; |
import java.awt.event.ActionListener; |
||||||
import java.awt.geom.Rectangle2D; |
import java.awt.geom.Rectangle2D; |
||||||
|
|
||||||
public class TextureBackgroundPane extends BackgroundSettingPane { |
public class TextureBackgroundQuickPane extends BackgroundQuickPane { |
||||||
|
|
||||||
private TexturePaint texturePaint; |
private TexturePaint texturePaint; |
||||||
private TextureButton[] textureButtonArray; |
private TextureButton[] textureButtonArray; |
||||||
|
|
||||||
public TextureBackgroundPane() { |
public TextureBackgroundQuickPane() { |
||||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
|
||||||
JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
borderPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5)); |
borderPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5)); |
||||||
JPanel contentPane = new JPanel(); |
JPanel contentPane = new JPanel(); |
||||||
borderPane.add(contentPane, BorderLayout.NORTH); |
borderPane.add(contentPane, BorderLayout.NORTH); |
||||||
this.add(borderPane, BorderLayout.NORTH); |
this.add(borderPane, BorderLayout.NORTH); |
||||||
contentPane.setLayout(new GridLayout(0, 8, 1, 1)); |
contentPane.setLayout(new GridLayout(0, 8, 1, 1)); |
||||||
contentPane.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); |
contentPane.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); |
||||||
borderPane.setPreferredSize(new Dimension(0, 145)); |
borderPane.setPreferredSize(new Dimension(0, 145)); |
||||||
ButtonGroup patternButtonGroup = new ButtonGroup(); |
ButtonGroup patternButtonGroup = new ButtonGroup(); |
||||||
textureButtonArray = new TextureButton[EMBED_TEXTURE_PAINT_ARRAY.length]; |
textureButtonArray = new TextureButton[EMBED_TEXTURE_PAINT_ARRAY.length]; |
||||||
for (int i = 0; i < EMBED_TEXTURE_PAINT_ARRAY.length; i++) { |
for (int i = 0; i < EMBED_TEXTURE_PAINT_ARRAY.length; i++) { |
||||||
textureButtonArray[i] = new TextureButton(EMBED_TEXTURE_PAINT_ARRAY[i], EMBED_TEXTURE_PAINT_DES_ARRAY[i]); |
textureButtonArray[i] = new TextureButton(EMBED_TEXTURE_PAINT_ARRAY[i], EMBED_TEXTURE_PAINT_DES_ARRAY[i]); |
||||||
patternButtonGroup.add(textureButtonArray[i]); |
patternButtonGroup.add(textureButtonArray[i]); |
||||||
contentPane.add(textureButtonArray[i]); |
contentPane.add(textureButtonArray[i]); |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
public void populateBean(Background background) { |
public void populateBean(Background background) { |
||||||
TextureBackground textureBackground = (TextureBackground) background; |
TextureBackground textureBackground = (TextureBackground) background; |
||||||
|
|
||||||
this.texturePaint = textureBackground.getTexturePaint(); |
this.texturePaint = textureBackground.getTexturePaint(); |
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < textureButtonArray.length; i++) { |
for (int i = 0; i < textureButtonArray.length; i++) { |
||||||
if (ComparatorUtils.equals(textureButtonArray[i].getTexturePaint(), this.texturePaint)) { |
if (ComparatorUtils.equals(textureButtonArray[i].getTexturePaint(), this.texturePaint)) { |
||||||
textureButtonArray[i].setSelected(true); |
textureButtonArray[i].setSelected(true); |
||||||
break; |
break; |
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
public Background updateBean() { |
public Background updateBean() { |
||||||
if (this.texturePaint == null) { |
if (this.texturePaint == null) { |
||||||
textureButtonArray[0].doClick(); |
textureButtonArray[0].doClick(); |
||||||
} |
} |
||||||
return new TextureBackground(this.texturePaint); |
return new TextureBackground(this.texturePaint); |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 给组件登记一个观察者监听事件 |
* 给组件登记一个观察者监听事件 |
||||||
* |
* |
||||||
* @param listener 观察者监听事件 |
* @param listener 观察者监听事件 |
||||||
*/ |
*/ |
||||||
public void registerChangeListener(final UIObserverListener listener) { |
public void registerChangeListener(final UIObserverListener listener) { |
||||||
for (int i = 0, count = textureButtonArray.length; i < count; i++) { |
for (int i = 0, count = textureButtonArray.length; i < count; i++) { |
||||||
textureButtonArray[i].addChangeListener(new ChangeListener() { |
textureButtonArray[i].addChangeListener(new ChangeListener() { |
||||||
public void stateChanged(ChangeEvent e) { |
public void stateChanged(ChangeEvent e) { |
||||||
listener.doChange(); |
listener.doChange(); |
||||||
} |
} |
||||||
}); |
}); |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
/** |
/** |
||||||
* Texture type button. |
* Texture type button. |
||||||
*/ |
*/ |
||||||
class TextureButton extends JToggleButton implements ActionListener { |
class TextureButton extends JToggleButton implements ActionListener { |
||||||
|
|
||||||
private TexturePaint buttonTexturePaint; |
private TexturePaint buttonTexturePaint; |
||||||
|
|
||||||
public TextureButton(TexturePaint buttonTexturePaint, String tooltip) { |
public TextureButton(TexturePaint buttonTexturePaint, String tooltip) { |
||||||
this.buttonTexturePaint = buttonTexturePaint; |
this.buttonTexturePaint = buttonTexturePaint; |
||||||
this.setToolTipText(tooltip); |
this.setToolTipText(tooltip); |
||||||
|
|
||||||
this.setCursor(new Cursor(Cursor.HAND_CURSOR)); |
this.setCursor(new Cursor(Cursor.HAND_CURSOR)); |
||||||
this.addActionListener(this); |
this.addActionListener(this); |
||||||
this.setBorder(null); |
this.setBorder(null); |
||||||
} |
} |
||||||
|
|
||||||
public void paintComponent(Graphics g) { |
public void paintComponent(Graphics g) { |
||||||
Graphics2D g2d = (Graphics2D) g; |
Graphics2D g2d = (Graphics2D) g; |
||||||
|
|
||||||
Dimension d = getSize(); |
Dimension d = getSize(); |
||||||
|
|
||||||
g2d.setPaint(this.buttonTexturePaint); |
g2d.setPaint(this.buttonTexturePaint); |
||||||
GraphHelper.fill(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); |
GraphHelper.fill(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); |
||||||
|
|
||||||
if (ComparatorUtils.equals(texturePaint, this.buttonTexturePaint)) {// it's
|
if (ComparatorUtils.equals(texturePaint, this.buttonTexturePaint)) {// it's
|
||||||
// selected.
|
// selected.
|
||||||
g2d.setPaint(UIConstants.LINE_COLOR); |
g2d.setPaint(UIConstants.LINE_COLOR); |
||||||
} else { |
} else { |
||||||
g2d.setPaint(null); |
g2d.setPaint(null); |
||||||
} |
} |
||||||
GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); |
GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); |
||||||
} |
} |
||||||
|
|
||||||
public Dimension getPreferredSize() { |
public Dimension getPreferredSize() { |
||||||
return new Dimension(super.getPreferredSize().width, 20); |
return new Dimension(super.getPreferredSize().width, 20); |
||||||
} |
} |
||||||
|
|
||||||
public TexturePaint getTexturePaint() { |
public TexturePaint getTexturePaint() { |
||||||
return this.buttonTexturePaint; |
return this.buttonTexturePaint; |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* set Pattern index. |
* set Pattern setIndex. |
||||||
*/ |
*/ |
||||||
public void actionPerformed(ActionEvent evt) { |
public void actionPerformed(ActionEvent evt) { |
||||||
TextureBackgroundPane.this.texturePaint = this.getTexturePaint(); |
TextureBackgroundQuickPane.this.texturePaint = this.getTexturePaint(); |
||||||
|
|
||||||
fireChagneListener(); |
fireChagneListener(); |
||||||
TextureBackgroundPane.this.repaint(); // repaint.
|
TextureBackgroundQuickPane.this.repaint(); // repaint.
|
||||||
} |
} |
||||||
|
|
||||||
public void addChangeListener(ChangeListener changeListener) { |
public void addChangeListener(ChangeListener changeListener) { |
||||||
this.changeListener = changeListener; |
this.changeListener = changeListener; |
||||||
} |
} |
||||||
|
|
||||||
private void fireChagneListener() { |
private void fireChagneListener() { |
||||||
if (this.changeListener != null) { |
if (this.changeListener != null) { |
||||||
ChangeEvent evt = new ChangeEvent(this); |
ChangeEvent evt = new ChangeEvent(this); |
||||||
this.changeListener.stateChanged(evt); |
this.changeListener.stateChanged(evt); |
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
public static final TexturePaint[] EMBED_TEXTURE_PAINT_ARRAY = new TexturePaint[]{TextureBackground.NEWSPRINT_TEXTURE_PAINT, TextureBackground.RECYCLED_PAPER_TEXTURE_PAINT, |
public static final TexturePaint[] EMBED_TEXTURE_PAINT_ARRAY = new TexturePaint[]{TextureBackground.NEWSPRINT_TEXTURE_PAINT, TextureBackground.RECYCLED_PAPER_TEXTURE_PAINT, |
||||||
TextureBackground.PARCHMENT_TEXTURE_PAINT, TextureBackground.STATIONERY_TEXTURE_PAINT, TextureBackground.GREEN_MARBLE_TEXTURE_PAINT, |
TextureBackground.PARCHMENT_TEXTURE_PAINT, TextureBackground.STATIONERY_TEXTURE_PAINT, TextureBackground.GREEN_MARBLE_TEXTURE_PAINT, |
||||||
TextureBackground.WHITE_MARBLE_TEXTURE_PAINT, TextureBackground.BROWN_MARBLE_TEXTURE_PAINT, TextureBackground.GRANITE_TEXTURE_PAINT, |
TextureBackground.WHITE_MARBLE_TEXTURE_PAINT, TextureBackground.BROWN_MARBLE_TEXTURE_PAINT, TextureBackground.GRANITE_TEXTURE_PAINT, |
||||||
TextureBackground.BLUE_TISSUE_PAPER_TEXTURE_PAINT, TextureBackground.PINK_TISSUE_PAPER_TEXTURE_PAINT, TextureBackground.PURPLE_MESH_TEXTURE_PAINT, |
TextureBackground.BLUE_TISSUE_PAPER_TEXTURE_PAINT, TextureBackground.PINK_TISSUE_PAPER_TEXTURE_PAINT, TextureBackground.PURPLE_MESH_TEXTURE_PAINT, |
||||||
TextureBackground.BOUQUET_TEXTURE_PAINT, TextureBackground.PAPYRUS_TEXTURE_PAINT, TextureBackground.CANVAS_TEXTURE_PAINT, TextureBackground.DENIM_TEXTURE_PAINT, |
TextureBackground.BOUQUET_TEXTURE_PAINT, TextureBackground.PAPYRUS_TEXTURE_PAINT, TextureBackground.CANVAS_TEXTURE_PAINT, TextureBackground.DENIM_TEXTURE_PAINT, |
||||||
TextureBackground.WOVEN_MAT_TEXTURE_PAINT, TextureBackground.WATER_DROPLETS_TEXTURE_PAINT, TextureBackground.PAPER_BAG_TEXTURE_PAINT, TextureBackground.FISH_FOSSIL_TEXTURE_PAINT, |
TextureBackground.WOVEN_MAT_TEXTURE_PAINT, TextureBackground.WATER_DROPLETS_TEXTURE_PAINT, TextureBackground.PAPER_BAG_TEXTURE_PAINT, TextureBackground.FISH_FOSSIL_TEXTURE_PAINT, |
||||||
TextureBackground.SAND_TEXTURE_PAINT, TextureBackground.CORK_TEXTURE_PAINT, TextureBackground.WALNUT_TEXTURE_PAINT, TextureBackground.OAK_TEXTURE_PAINT, |
TextureBackground.SAND_TEXTURE_PAINT, TextureBackground.CORK_TEXTURE_PAINT, TextureBackground.WALNUT_TEXTURE_PAINT, TextureBackground.OAK_TEXTURE_PAINT, |
||||||
TextureBackground.MEDIUM_WOOD_TEXTURE_PAINT}; |
TextureBackground.MEDIUM_WOOD_TEXTURE_PAINT}; |
||||||
private static final String[] EMBED_TEXTURE_PAINT_DES_ARRAY = new String[]{Inter.getLocText("BackgroundTexture-Newsprint"), Inter.getLocText("BackgroundTexture-RecycledPaper"), |
private static final String[] EMBED_TEXTURE_PAINT_DES_ARRAY = new String[]{Inter.getLocText("BackgroundTexture-Newsprint"), Inter.getLocText("BackgroundTexture-RecycledPaper"), |
||||||
Inter.getLocText("BackgroundTexture-Parchment"), Inter.getLocText("BackgroundTexture-Stationery"), Inter.getLocText("BackgroundTexture-GreenMarble"), |
Inter.getLocText("BackgroundTexture-Parchment"), Inter.getLocText("BackgroundTexture-Stationery"), Inter.getLocText("BackgroundTexture-GreenMarble"), |
||||||
Inter.getLocText("BackgroundTexture-WhiteMarble"), Inter.getLocText("BackgroundTexture-BrownMarble"), Inter.getLocText("BackgroundTexture-Granite"), |
Inter.getLocText("BackgroundTexture-WhiteMarble"), Inter.getLocText("BackgroundTexture-BrownMarble"), Inter.getLocText("BackgroundTexture-Granite"), |
||||||
Inter.getLocText("BackgroundTexture-BlueTissuePaper"), Inter.getLocText("BackgroundTexture-PinkTissuePaper"), Inter.getLocText("BackgroundTexture-PurpleMesh"), |
Inter.getLocText("BackgroundTexture-BlueTissuePaper"), Inter.getLocText("BackgroundTexture-PinkTissuePaper"), Inter.getLocText("BackgroundTexture-PurpleMesh"), |
||||||
Inter.getLocText("BackgroundTexture-Bouquet"), Inter.getLocText("BackgroundTexture-Papyrus"), Inter.getLocText("BackgroundTexture-Canvas"), |
Inter.getLocText("BackgroundTexture-Bouquet"), Inter.getLocText("BackgroundTexture-Papyrus"), Inter.getLocText("BackgroundTexture-Canvas"), |
||||||
Inter.getLocText("BackgroundTexture-Denim"), Inter.getLocText("BackgroundTexture-WovenMat"), Inter.getLocText("BackgroundTexture-WaterDroplets"), |
Inter.getLocText("BackgroundTexture-Denim"), Inter.getLocText("BackgroundTexture-WovenMat"), Inter.getLocText("BackgroundTexture-WaterDroplets"), |
||||||
Inter.getLocText("BackgroundTexture-PaperBag"), Inter.getLocText("BackgroundTexture-FishFossil"), Inter.getLocText("BackgroundTexture-Sand"), |
Inter.getLocText("BackgroundTexture-PaperBag"), Inter.getLocText("BackgroundTexture-FishFossil"), Inter.getLocText("BackgroundTexture-Sand"), |
||||||
Inter.getLocText("BackgroundTexture-Cork"), Inter.getLocText("BackgroundTexture-Walnut"), Inter.getLocText("BackgroundTexture-Oak"), |
Inter.getLocText("BackgroundTexture-Cork"), Inter.getLocText("BackgroundTexture-Walnut"), Inter.getLocText("BackgroundTexture-Oak"), |
||||||
Inter.getLocText("BackgroundTexture-MediumWood")}; |
Inter.getLocText("BackgroundTexture-MediumWood")}; |
||||||
|
|
||||||
@Override |
@Override |
||||||
public boolean accept(Background background) { |
public boolean accept(Background background) { |
||||||
return background instanceof TextureBackground; |
return background instanceof TextureBackground; |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public String title4PopupWindow() { |
public String title4PopupWindow() { |
||||||
return Inter.getLocText("Background-Texture"); |
return Inter.getLocText("Background-Texture"); |
||||||
} |
} |
||||||
} |
} |
@ -0,0 +1,6 @@ |
|||||||
|
package com.fr.design; |
||||||
|
|
||||||
|
public class mingche |
||||||
|
{ |
||||||
|
|
||||||
|
} |
@ -0,0 +1,18 @@ |
|||||||
|
package com.fr.design.style.background; |
||||||
|
|
||||||
|
import com.fr.general.Background; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import javax.swing.event.ChangeListener; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 16/5/18. |
||||||
|
*/ |
||||||
|
public abstract class BackgroundDetailPane extends JPanel { |
||||||
|
|
||||||
|
public abstract void populate(Background background); |
||||||
|
|
||||||
|
public abstract Background update() throws Exception; |
||||||
|
|
||||||
|
public abstract void addChangeListener(ChangeListener changeListener); |
||||||
|
} |
@ -0,0 +1,121 @@ |
|||||||
|
package com.fr.design.style.background; |
||||||
|
|
||||||
|
|
||||||
|
import com.fr.base.background.*; |
||||||
|
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.general.Background; |
||||||
|
import com.fr.general.Inter; |
||||||
|
|
||||||
|
import java.util.LinkedHashMap; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.Set; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 16/5/18. |
||||||
|
*/ |
||||||
|
public class BackgroundFactory { |
||||||
|
|
||||||
|
private static Map<Class<? extends Background>, BackgroundUIWrapper> map = new LinkedHashMap<>(); |
||||||
|
private static Map<Class<? extends Background>, BackgroundUIWrapper> browser = new LinkedHashMap<>(); |
||||||
|
|
||||||
|
static { |
||||||
|
registerUniversal(map); |
||||||
|
registerImageBackground(map); |
||||||
|
registerUniversal(browser); |
||||||
|
registerBrowserImageBackground(browser); |
||||||
|
registerExtra(map); |
||||||
|
registerExtra(browser); |
||||||
|
} |
||||||
|
|
||||||
|
private static void registerUniversal(Map<Class<? extends Background>, BackgroundUIWrapper> map) { |
||||||
|
map.put(null, BackgroundUIWrapper.create() |
||||||
|
.setType(NullBackgroundPane.class).setTitle(Inter.getLocText("Background-Null"))); |
||||||
|
map.put(ColorBackground.class, BackgroundUIWrapper.create() |
||||||
|
.setType(ColorBackgroundPane.class).setTitle(Inter.getLocText("Color"))); |
||||||
|
map.put(TextureBackground.class, BackgroundUIWrapper.create() |
||||||
|
.setType(TextureBackgroundPane.class).setTitle(Inter.getLocText("Background-Texture"))); |
||||||
|
map.put(PatternBackground.class, BackgroundUIWrapper.create() |
||||||
|
.setType(PatternBackgroundPane.class).setTitle(Inter.getLocText("Background-Pattern"))); |
||||||
|
map.put(GradientBackground.class, BackgroundUIWrapper.create() |
||||||
|
.setType(GradientBackgroundPane.class).setTitle(Inter.getLocText("Gradient-Color"))); |
||||||
|
} |
||||||
|
|
||||||
|
private static void registerImageBackground(Map<Class<? extends Background>, BackgroundUIWrapper> map) { |
||||||
|
map.put(ImageBackground.class, BackgroundUIWrapper.create() |
||||||
|
.setType(ImageBackgroundPane.class).setTitle(Inter.getLocText("Image"))); |
||||||
|
} |
||||||
|
|
||||||
|
private static void registerBrowserImageBackground(Map<Class<? extends Background>, BackgroundUIWrapper> map) { |
||||||
|
map.put(ImageBackground.class, BackgroundUIWrapper.create() |
||||||
|
.setType(ImageBackgroundPane4Browser.class).setTitle(Inter.getLocText("Image"))); |
||||||
|
} |
||||||
|
|
||||||
|
private static void registerExtra(Map<Class<? extends Background>, BackgroundUIWrapper> map) { |
||||||
|
for (BackgroundUIProvider provider : ExtraDesignClassManager.getInstance().getBackgroundUIProviders()) { |
||||||
|
map.put(provider.targetClass(), BackgroundUIWrapper.create() |
||||||
|
.setType(provider.targetUIClass()).setTitle(provider.targetTitle())); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public static Set<Class<? extends Background>> kindsOfKey() { |
||||||
|
return map.keySet(); |
||||||
|
} |
||||||
|
|
||||||
|
public static BackgroundUIWrapper getWrapper(Class<? extends Background> category) { |
||||||
|
return map.get(category); |
||||||
|
} |
||||||
|
|
||||||
|
public static BackgroundDetailPane createIfAbsent(Class<? extends Background> category) { |
||||||
|
BackgroundUIWrapper wrapper = map.get(category); |
||||||
|
return createByWrapper(wrapper); |
||||||
|
} |
||||||
|
|
||||||
|
public static BackgroundDetailPane createIfAbsent(int index) { |
||||||
|
for (BackgroundUIWrapper wrapper : map.values()) { |
||||||
|
if (wrapper.getIndex() == index) { |
||||||
|
return createByWrapper(wrapper); |
||||||
|
} |
||||||
|
} |
||||||
|
return new NullBackgroundPane(); |
||||||
|
} |
||||||
|
|
||||||
|
public static Set<Class<? extends Background>> browserKindsOfKey() { |
||||||
|
return browser.keySet(); |
||||||
|
} |
||||||
|
|
||||||
|
public static BackgroundUIWrapper getBrowserWrapper(Class<? extends Background> category) { |
||||||
|
return browser.get(category); |
||||||
|
} |
||||||
|
|
||||||
|
public static BackgroundDetailPane createBrowserIfAbsent(Class<? extends Background> category) { |
||||||
|
BackgroundUIWrapper wrapper = browser.get(category); |
||||||
|
return createByWrapper(wrapper); |
||||||
|
} |
||||||
|
|
||||||
|
public static BackgroundDetailPane createBrowserIfAbsent(int index) { |
||||||
|
for (BackgroundUIWrapper wrapper : browser.values()) { |
||||||
|
if (wrapper.getIndex() == index) { |
||||||
|
return createByWrapper(wrapper); |
||||||
|
} |
||||||
|
} |
||||||
|
return new NullBackgroundPane(); |
||||||
|
} |
||||||
|
|
||||||
|
private static BackgroundDetailPane createByWrapper(BackgroundUIWrapper wrapper) { |
||||||
|
Class<? extends BackgroundDetailPane> clazz = wrapper.getType(); |
||||||
|
if (clazz == null) { |
||||||
|
clazz = NullBackgroundPane.class; |
||||||
|
} |
||||||
|
BackgroundDetailPane quickPane; |
||||||
|
try { |
||||||
|
quickPane = clazz.newInstance(); |
||||||
|
} catch (Exception e) { |
||||||
|
quickPane = new NullBackgroundPane(); |
||||||
|
} |
||||||
|
return quickPane; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,51 @@ |
|||||||
|
package com.fr.design.style.background; |
||||||
|
|
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.general.Background; |
||||||
|
import com.fr.general.Inter; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 16/5/18. |
||||||
|
*/ |
||||||
|
public class BackgroundPane4Browser extends BackgroundPane { |
||||||
|
|
||||||
|
public BackgroundPane4Browser() { |
||||||
|
super(); |
||||||
|
} |
||||||
|
|
||||||
|
protected void initTabPane() { |
||||||
|
int index = 0; |
||||||
|
for (Class<? extends Background> key : BackgroundFactory.browserKindsOfKey()) { |
||||||
|
BackgroundUIWrapper wrapper = BackgroundFactory.getBrowserWrapper(key); |
||||||
|
wrapper.setIndex(index++); |
||||||
|
tabbedPane.addTab(Inter.getLocText(wrapper.getTitle()), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
protected BackgroundUIWrapper getBackgroundUIWrapper(Background background) { |
||||||
|
return BackgroundFactory.getBrowserWrapper(background == null ? null : background.getClass()); |
||||||
|
} |
||||||
|
|
||||||
|
protected BackgroundDetailPane getTabItemPane(Background background, int index) { |
||||||
|
BackgroundDetailPane quickPane = cacheMap.get(index); |
||||||
|
if (quickPane == null) { |
||||||
|
quickPane = BackgroundFactory.createBrowserIfAbsent(background == null ? null : background.getClass()); |
||||||
|
quickPane.addChangeListener(backgroundChangeListener); |
||||||
|
cacheMap.put(index, quickPane); |
||||||
|
} |
||||||
|
tabbedPane.setComponentAt(index, quickPane); |
||||||
|
tabbedPane.setSelectedIndex(index); |
||||||
|
return quickPane; |
||||||
|
} |
||||||
|
|
||||||
|
protected BackgroundDetailPane getTabItemPaneByIndex(int index) { |
||||||
|
BackgroundDetailPane quickPane = cacheMap.get(index); |
||||||
|
if (quickPane == null) { |
||||||
|
quickPane = BackgroundFactory.createBrowserIfAbsent(index); |
||||||
|
tabbedPane.setComponentAt(index, quickPane); |
||||||
|
cacheMap.put(index, quickPane); |
||||||
|
quickPane.addChangeListener(backgroundChangeListener); |
||||||
|
} |
||||||
|
return quickPane; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,49 @@ |
|||||||
|
package com.fr.design.style.background; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 16/5/18. |
||||||
|
*/ |
||||||
|
public class BackgroundUIWrapper { |
||||||
|
|
||||||
|
public static BackgroundUIWrapper create() { |
||||||
|
return new BackgroundUIWrapper(); |
||||||
|
} |
||||||
|
|
||||||
|
private int index = -1; |
||||||
|
private String title; |
||||||
|
private Class<? extends BackgroundDetailPane> clazz; |
||||||
|
|
||||||
|
private BackgroundUIWrapper() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public Class<? extends BackgroundDetailPane> getType() { |
||||||
|
return clazz; |
||||||
|
} |
||||||
|
|
||||||
|
public BackgroundUIWrapper setType(Class<? extends BackgroundDetailPane> clazz) { |
||||||
|
this.clazz = clazz; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public String getTitle() { |
||||||
|
return title; |
||||||
|
} |
||||||
|
|
||||||
|
public BackgroundUIWrapper setTitle(String title) { |
||||||
|
this.title = title; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public int getIndex() { |
||||||
|
return index; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public BackgroundUIWrapper setIndex(int index) { |
||||||
|
if (this.index == -1) { |
||||||
|
this.index = index; |
||||||
|
} |
||||||
|
return this; |
||||||
|
} |
||||||
|
} |
@ -1,135 +1,135 @@ |
|||||||
package com.fr.design.style.background.gradient; |
package com.fr.design.style.background.gradient; |
||||||
|
|
||||||
import java.awt.BorderLayout; |
import java.awt.BorderLayout; |
||||||
import java.awt.Dimension; |
import java.awt.Dimension; |
||||||
import java.awt.event.ActionEvent; |
import java.awt.event.ActionEvent; |
||||||
import java.awt.event.ActionListener; |
import java.awt.event.ActionListener; |
||||||
|
|
||||||
import javax.swing.ButtonGroup; |
import javax.swing.ButtonGroup; |
||||||
|
|
||||||
import com.fr.design.gui.ibutton.UIRadioButton; |
import com.fr.design.gui.ibutton.UIRadioButton; |
||||||
import com.fr.design.gui.ilable.UILabel; |
import com.fr.design.gui.ilable.UILabel; |
||||||
import javax.swing.JPanel; |
import javax.swing.JPanel; |
||||||
import javax.swing.SwingConstants; |
import javax.swing.SwingConstants; |
||||||
import javax.swing.event.ChangeEvent; |
import javax.swing.event.ChangeEvent; |
||||||
import javax.swing.event.ChangeListener; |
import javax.swing.event.ChangeListener; |
||||||
|
|
||||||
import com.fr.base.background.GradientBackground; |
import com.fr.base.background.GradientBackground; |
||||||
import com.fr.design.layout.FRGUIPaneFactory; |
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
import com.fr.general.Background; |
import com.fr.general.Background; |
||||||
import com.fr.general.Inter; |
import com.fr.general.Inter; |
||||||
import com.fr.design.style.background.BackgroundPane.BackgroundSettingPane; |
import com.fr.design.style.background.BackgroundDetailPane; |
||||||
|
|
||||||
/** |
/** |
||||||
* 渐变色的面板,不是很pp,面板应用显得繁琐,有写可以写成控件类型,比如色彩选择的。。,可以做得花哨点 |
* 渐变色的面板,不是很pp,面板应用显得繁琐,有写可以写成控件类型,比如色彩选择的。。,可以做得花哨点 |
||||||
* @author ben |
* @author ben |
||||||
*/ |
*/ |
||||||
public class GradientPane extends BackgroundSettingPane { |
public class GradientBackgroundPane extends BackgroundDetailPane { |
||||||
private static final long serialVersionUID = -6854603990673031897L; |
private static final long serialVersionUID = -6854603990673031897L; |
||||||
|
|
||||||
private UIRadioButton left2right, top2bottom; |
private UIRadioButton left2right, top2bottom; |
||||||
private GradientBar gradientBar; |
private GradientBar gradientBar; |
||||||
private ChangeListener changeListener = null; |
private ChangeListener changeListener = null; |
||||||
|
|
||||||
public GradientPane() { |
public GradientBackgroundPane() { |
||||||
|
|
||||||
// bug 5452 简化GradientPane
|
// bug 5452 简化GradientPane
|
||||||
JPanel jpanel = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText(new String[]{"Gradient-Color", "Set"})); |
JPanel jpanel = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText(new String[]{"Gradient-Color", "Set"})); |
||||||
jpanel.setPreferredSize(new Dimension(450, 320)); |
jpanel.setPreferredSize(new Dimension(450, 320)); |
||||||
jpanel.setLayout(new BorderLayout()); |
jpanel.setLayout(new BorderLayout()); |
||||||
|
|
||||||
// neil:增加渐变色拖动条
|
// neil:增加渐变色拖动条
|
||||||
JPanel gradientPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
JPanel gradientPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
JPanel blankJp = new JPanel(); |
JPanel blankJp = new JPanel(); |
||||||
gradientBar = new GradientBar(4, 254); |
gradientBar = new GradientBar(4, 254); |
||||||
blankJp.add(gradientBar); |
blankJp.add(gradientBar); |
||||||
UILabel jl = new UILabel(Inter.getLocText("Drag_to_select_gradient")); |
UILabel jl = new UILabel(Inter.getLocText("Drag_to_select_gradient")); |
||||||
jl.setHorizontalAlignment(SwingConstants.CENTER); |
jl.setHorizontalAlignment(SwingConstants.CENTER); |
||||||
gradientPanel.add(jl, BorderLayout.NORTH); |
gradientPanel.add(jl, BorderLayout.NORTH); |
||||||
gradientPanel.add(blankJp, BorderLayout.SOUTH); |
gradientPanel.add(blankJp, BorderLayout.SOUTH); |
||||||
jpanel.add(gradientPanel, BorderLayout.NORTH); |
jpanel.add(gradientPanel, BorderLayout.NORTH); |
||||||
|
|
||||||
JPanel centerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); |
JPanel centerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); |
||||||
JPanel innercenterPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); |
JPanel innercenterPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); |
||||||
centerPane.add(new UILabel(" ")); |
centerPane.add(new UILabel(" ")); |
||||||
centerPane.add(innercenterPane); |
centerPane.add(innercenterPane); |
||||||
innercenterPane.add(new UILabel(Inter.getLocText("Gradient-Direction") + ":")); |
innercenterPane.add(new UILabel(Inter.getLocText("Gradient-Direction") + ":")); |
||||||
|
|
||||||
left2right = new UIRadioButton(Inter.getLocText("PageSetup-Landscape")); |
left2right = new UIRadioButton(Inter.getLocText("PageSetup-Landscape")); |
||||||
innercenterPane.add(left2right); |
innercenterPane.add(left2right); |
||||||
left2right.setSelected(true); |
left2right.setSelected(true); |
||||||
left2right.addActionListener(reviewListener); |
left2right.addActionListener(reviewListener); |
||||||
|
|
||||||
top2bottom = new UIRadioButton(Inter.getLocText("PageSetup-Portrait")); |
top2bottom = new UIRadioButton(Inter.getLocText("PageSetup-Portrait")); |
||||||
innercenterPane.add(top2bottom); |
innercenterPane.add(top2bottom); |
||||||
top2bottom.addActionListener(reviewListener); |
top2bottom.addActionListener(reviewListener); |
||||||
|
|
||||||
ButtonGroup toggle = new ButtonGroup(); |
ButtonGroup toggle = new ButtonGroup(); |
||||||
toggle.add(left2right); |
toggle.add(left2right); |
||||||
toggle.add(top2bottom); |
toggle.add(top2bottom); |
||||||
jpanel.add(centerPane, BorderLayout.CENTER); |
jpanel.add(centerPane, BorderLayout.CENTER); |
||||||
|
|
||||||
this.add(jpanel); |
this.add(jpanel); |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
public void populate(Background background) { |
public void populate(Background background) { |
||||||
if (!(background instanceof GradientBackground)) { |
if (!(background instanceof GradientBackground)) { |
||||||
return; |
return; |
||||||
} |
} |
||||||
GradientBackground bg = (GradientBackground) background; |
GradientBackground bg = (GradientBackground) background; |
||||||
this.gradientBar.getSelectColorPointBtnP1().setColorInner(bg.getStartColor()); |
this.gradientBar.getSelectColorPointBtnP1().setColorInner(bg.getStartColor()); |
||||||
this.gradientBar.getSelectColorPointBtnP2().setColorInner(bg.getEndColor()); |
this.gradientBar.getSelectColorPointBtnP2().setColorInner(bg.getEndColor()); |
||||||
if (bg.getDirection() == GradientBackground.LEFT2RIGHT) { |
if (bg.getDirection() == GradientBackground.LEFT2RIGHT) { |
||||||
left2right.setSelected(true); |
left2right.setSelected(true); |
||||||
} else { |
} else { |
||||||
top2bottom.setSelected(true); |
top2bottom.setSelected(true); |
||||||
} |
} |
||||||
if (bg.isUseCell()) { |
if (bg.isUseCell()) { |
||||||
return; |
return; |
||||||
} |
} |
||||||
double startValue = (double) bg.getBeginPlace(); |
double startValue = (double) bg.getBeginPlace(); |
||||||
double endValue = (double) bg.getFinishPlace(); |
double endValue = (double) bg.getFinishPlace(); |
||||||
gradientBar.setStartValue(startValue); |
gradientBar.setStartValue(startValue); |
||||||
gradientBar.setEndValue(endValue); |
gradientBar.setEndValue(endValue); |
||||||
this.gradientBar.repaint(); |
this.gradientBar.repaint(); |
||||||
} |
} |
||||||
|
|
||||||
public GradientBackground update() { |
public GradientBackground update() { |
||||||
GradientBackground gb = new GradientBackground( |
GradientBackground gb = new GradientBackground( |
||||||
gradientBar.getSelectColorPointBtnP1().getColorInner(), |
gradientBar.getSelectColorPointBtnP1().getColorInner(), |
||||||
gradientBar.getSelectColorPointBtnP2().getColorInner()); |
gradientBar.getSelectColorPointBtnP2().getColorInner()); |
||||||
if (left2right.isSelected()) { |
if (left2right.isSelected()) { |
||||||
gb.setDirection(GradientBackground.LEFT2RIGHT); |
gb.setDirection(GradientBackground.LEFT2RIGHT); |
||||||
} else { |
} else { |
||||||
gb.setDirection(GradientBackground.TOP2BOTTOM); |
gb.setDirection(GradientBackground.TOP2BOTTOM); |
||||||
} |
} |
||||||
if (gradientBar.isOriginalPlace()) { |
if (gradientBar.isOriginalPlace()) { |
||||||
gb.setUseCell(true); |
gb.setUseCell(true); |
||||||
} else { |
} else { |
||||||
gb.setUseCell(false); |
gb.setUseCell(false); |
||||||
gb.setBeginPlace((float) gradientBar.getStartValue()); |
gb.setBeginPlace((float) gradientBar.getStartValue()); |
||||||
gb.setFinishPlace((float) gradientBar.getEndValue()); |
gb.setFinishPlace((float) gradientBar.getEndValue()); |
||||||
} |
} |
||||||
return gb; |
return gb; |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
ActionListener reviewListener = new ActionListener() { |
ActionListener reviewListener = new ActionListener() { |
||||||
public void actionPerformed(ActionEvent e) { |
public void actionPerformed(ActionEvent e) { |
||||||
fireChagneListener(); |
fireChagneListener(); |
||||||
} |
} |
||||||
}; |
}; |
||||||
|
|
||||||
public void addChangeListener(ChangeListener changeListener) { |
public void addChangeListener(ChangeListener changeListener) { |
||||||
this.changeListener = changeListener; |
this.changeListener = changeListener; |
||||||
gradientBar.addChangeListener(changeListener); |
gradientBar.addChangeListener(changeListener); |
||||||
} |
} |
||||||
|
|
||||||
public void fireChagneListener() { |
public void fireChagneListener() { |
||||||
if (this.changeListener != null) { |
if (this.changeListener != null) { |
||||||
ChangeEvent evt = new ChangeEvent(this); |
ChangeEvent evt = new ChangeEvent(this); |
||||||
this.changeListener.stateChanged(evt); |
this.changeListener.stateChanged(evt); |
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
@ -0,0 +1,46 @@ |
|||||||
|
package com.fr.design.style.background.impl; |
||||||
|
|
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.style.background.BackgroundDetailPane; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 16/5/18. |
||||||
|
*/ |
||||||
|
public abstract class BPane extends BackgroundDetailPane { |
||||||
|
|
||||||
|
public BPane(int nColumn) { |
||||||
|
this.initComponents(nColumn); |
||||||
|
} |
||||||
|
|
||||||
|
private void initComponents(int nColumn) { |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
this.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); |
||||||
|
|
||||||
|
JPanel contentPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); |
||||||
|
this.add(contentPane, BorderLayout.NORTH); |
||||||
|
// contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
|
// type type.
|
||||||
|
|
||||||
|
JPanel typePane = FRGUIPaneFactory.createTitledBorderPane(titleOfTypePane()); |
||||||
|
contentPane.add(typePane); |
||||||
|
JPanel typePane2 = new JPanel(); |
||||||
|
typePane.add(typePane2); |
||||||
|
typePane2.setLayout(layoutOfTypePane(nColumn)); |
||||||
|
setChildrenOfTypePane(typePane2); |
||||||
|
|
||||||
|
setChildrenOfContentPane(contentPane); |
||||||
|
} |
||||||
|
|
||||||
|
protected abstract String titleOfTypePane(); |
||||||
|
|
||||||
|
protected abstract LayoutManager layoutOfTypePane(int nColumn); |
||||||
|
|
||||||
|
protected abstract void setChildrenOfTypePane(JPanel typePane2); |
||||||
|
|
||||||
|
protected void setChildrenOfContentPane(JPanel contentPane) { |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,42 @@ |
|||||||
|
package com.fr.design.style.background.impl; |
||||||
|
|
||||||
|
import com.fr.base.background.ColorBackground; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.style.background.BackgroundDetailPane; |
||||||
|
import com.fr.design.style.color.DetailColorSelectPane; |
||||||
|
import com.fr.general.Background; |
||||||
|
|
||||||
|
import javax.swing.event.ChangeListener; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* Color background pane. |
||||||
|
*/ |
||||||
|
public class ColorBackgroundPane extends BackgroundDetailPane { |
||||||
|
|
||||||
|
private DetailColorSelectPane detailColorSelectPane; |
||||||
|
|
||||||
|
public ColorBackgroundPane() { |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
|
||||||
|
detailColorSelectPane = new DetailColorSelectPane(); |
||||||
|
this.add(detailColorSelectPane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
public void populate(Background background) { |
||||||
|
if (background instanceof ColorBackground) { |
||||||
|
ColorBackground colorBackgroud = (ColorBackground) background; |
||||||
|
this.detailColorSelectPane.populate(colorBackgroud.getColor()); |
||||||
|
} else { |
||||||
|
this.detailColorSelectPane.populate(Color.white); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public Background update() throws Exception { |
||||||
|
return ColorBackground.getInstance(this.detailColorSelectPane.update()); |
||||||
|
} |
||||||
|
|
||||||
|
public void addChangeListener(ChangeListener changeListener) { |
||||||
|
detailColorSelectPane.addChangeListener(changeListener); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,230 @@ |
|||||||
|
package com.fr.design.style.background.impl; |
||||||
|
|
||||||
|
import com.fr.base.BaseUtils; |
||||||
|
import com.fr.base.Style; |
||||||
|
import com.fr.base.background.ImageBackground; |
||||||
|
import com.fr.design.gui.ibutton.UIButton; |
||||||
|
import com.fr.design.gui.ibutton.UIRadioButton; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.style.background.BackgroundDetailPane; |
||||||
|
import com.fr.design.style.background.image.ImageFileChooser; |
||||||
|
import com.fr.design.style.background.image.ImagePreviewPane; |
||||||
|
import com.fr.general.Background; |
||||||
|
import com.fr.general.Inter; |
||||||
|
import com.fr.stable.Constants; |
||||||
|
import com.fr.stable.CoreGraphHelper; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import javax.swing.event.ChangeEvent; |
||||||
|
import javax.swing.event.ChangeListener; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
import java.io.File; |
||||||
|
|
||||||
|
/** |
||||||
|
* Image background pane. |
||||||
|
*/ |
||||||
|
public class ImageBackgroundPane extends BackgroundDetailPane { |
||||||
|
|
||||||
|
private ImagePreviewPane previewPane = null; |
||||||
|
private Style imageStyle = null; |
||||||
|
private ChangeListener changeListener = null; |
||||||
|
private ImageFileChooser imageFileChooser = null; |
||||||
|
private UILabel imageSizeLabel = new UILabel(); |
||||||
|
|
||||||
|
protected JRadioButton defaultRadioButton = null; |
||||||
|
protected JRadioButton tiledRadioButton = null; |
||||||
|
private JRadioButton extendRadioButton = null; |
||||||
|
private JRadioButton adjustRadioButton = null; |
||||||
|
|
||||||
|
public ImageBackgroundPane() { |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
|
||||||
|
// preview pane
|
||||||
|
JPanel previewContainerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||||
|
this.add(previewContainerPane, BorderLayout.CENTER); |
||||||
|
|
||||||
|
JPanel previewOwnerPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("Preview")); |
||||||
|
previewOwnerPane.setLayout(new BorderLayout()); |
||||||
|
previewContainerPane.add(previewOwnerPane, BorderLayout.CENTER); |
||||||
|
|
||||||
|
|
||||||
|
previewPane = new ImagePreviewPane(); |
||||||
|
previewOwnerPane.add(new JScrollPane(previewPane)); |
||||||
|
previewPane.addChangeListener(imageSizeChangeListener); |
||||||
|
|
||||||
|
JPanel selectFilePane = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||||
|
previewContainerPane.add(selectFilePane, BorderLayout.EAST); |
||||||
|
selectFilePane.setBorder(BorderFactory.createEmptyBorder(8, 2, 4, 0)); |
||||||
|
|
||||||
|
UIButton selectPictureButton = new UIButton( |
||||||
|
Inter.getLocText("Image-Select_Picture")); |
||||||
|
selectFilePane.add(selectPictureButton, BorderLayout.NORTH); |
||||||
|
selectPictureButton.setMnemonic('S'); |
||||||
|
selectPictureButton.addActionListener(selectPictureActionListener); |
||||||
|
JPanel layoutPane = FRGUIPaneFactory.createMediumHGapHighTopFlowInnerContainer_M_Pane(); |
||||||
|
selectFilePane.add(layoutPane, BorderLayout.CENTER); |
||||||
|
|
||||||
|
//布局
|
||||||
|
defaultRadioButton = new UIRadioButton(Inter.getLocText("Default")); |
||||||
|
tiledRadioButton = new UIRadioButton(Inter.getLocText("Image-Titled")); |
||||||
|
extendRadioButton = new UIRadioButton(Inter.getLocText("Image-Extend")); |
||||||
|
adjustRadioButton = new UIRadioButton(Inter.getLocText("Image-Adjust")); |
||||||
|
|
||||||
|
defaultRadioButton.addActionListener(layoutActionListener); |
||||||
|
tiledRadioButton.addActionListener(layoutActionListener); |
||||||
|
extendRadioButton.addActionListener(layoutActionListener); |
||||||
|
adjustRadioButton.addActionListener(layoutActionListener); |
||||||
|
|
||||||
|
JPanel jp = new JPanel(new GridLayout(4, 1, 15, 15)); |
||||||
|
for (JRadioButton button : imageLayoutButtons()) { |
||||||
|
jp.add(button); |
||||||
|
} |
||||||
|
layoutPane.add(jp); |
||||||
|
|
||||||
|
ButtonGroup layoutBG = new ButtonGroup(); |
||||||
|
layoutBG.add(defaultRadioButton); |
||||||
|
layoutBG.add(tiledRadioButton); |
||||||
|
layoutBG.add(extendRadioButton); |
||||||
|
layoutBG.add(adjustRadioButton); |
||||||
|
|
||||||
|
defaultRadioButton.setSelected(true); |
||||||
|
|
||||||
|
// init image file chooser.
|
||||||
|
imageFileChooser = new ImageFileChooser(); |
||||||
|
imageFileChooser.setMultiSelectionEnabled(false); |
||||||
|
} |
||||||
|
|
||||||
|
protected JRadioButton[] imageLayoutButtons() { |
||||||
|
return new JRadioButton[]{ |
||||||
|
defaultRadioButton, |
||||||
|
tiledRadioButton, |
||||||
|
extendRadioButton, |
||||||
|
adjustRadioButton |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Select picture. |
||||||
|
*/ |
||||||
|
ActionListener selectPictureActionListener = new ActionListener() { |
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent evt) { |
||||||
|
int returnVal = imageFileChooser.showOpenDialog(ImageBackgroundPane.this); |
||||||
|
if (returnVal != JFileChooser.CANCEL_OPTION) { |
||||||
|
File selectedFile = imageFileChooser.getSelectedFile(); |
||||||
|
|
||||||
|
if (selectedFile != null && selectedFile.isFile()) { |
||||||
|
Image image = BaseUtils.readImage(selectedFile.getPath()); |
||||||
|
CoreGraphHelper.waitForImage(image); |
||||||
|
|
||||||
|
previewPane.setImage(image); |
||||||
|
setImageStyle(); |
||||||
|
previewPane.setImageStyle(imageStyle); |
||||||
|
previewPane.repaint(); |
||||||
|
} else { |
||||||
|
previewPane.setImage(null); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
fireChagneListener(); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
private void setImageStyle() { |
||||||
|
if (tiledRadioButton.isSelected()) { |
||||||
|
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_TILED); |
||||||
|
} else if (adjustRadioButton.isSelected()) { |
||||||
|
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_ADJUST); |
||||||
|
} else if (extendRadioButton.isSelected()) { |
||||||
|
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_EXTEND); |
||||||
|
} else { |
||||||
|
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_CENTER); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
ActionListener layoutActionListener = new ActionListener() { |
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent evt) { |
||||||
|
setImageStyle(); |
||||||
|
changeImageStyle(); |
||||||
|
} |
||||||
|
|
||||||
|
private void changeImageStyle() { |
||||||
|
previewPane.setImageStyle(ImageBackgroundPane.this.imageStyle); |
||||||
|
previewPane.repaint(); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
public void populate(Background background) { |
||||||
|
|
||||||
|
if (background instanceof ImageBackground) { |
||||||
|
ImageBackground imageBackground = (ImageBackground) background; |
||||||
|
|
||||||
|
if (imageBackground.getLayout() == Constants.IMAGE_CENTER) { |
||||||
|
defaultRadioButton.setSelected(true); |
||||||
|
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_CENTER); |
||||||
|
} else if (imageBackground.getLayout() == Constants.IMAGE_EXTEND) { |
||||||
|
extendRadioButton.setSelected(true); |
||||||
|
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_EXTEND); |
||||||
|
} else if (imageBackground.getLayout() == Constants.IMAGE_ADJUST) { |
||||||
|
adjustRadioButton.setSelected(true); |
||||||
|
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_ADJUST); |
||||||
|
} else { |
||||||
|
tiledRadioButton.setSelected(true); |
||||||
|
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_TILED); |
||||||
|
} |
||||||
|
|
||||||
|
previewPane.setImageStyle(ImageBackgroundPane.this.imageStyle); |
||||||
|
if (imageBackground.getImage() != null) { |
||||||
|
previewPane.setImage(imageBackground.getImage()); |
||||||
|
imageSizeLabel.setText(previewPane.getImage().getWidth(null) |
||||||
|
+ " X " + previewPane.getImage().getHeight(null)); |
||||||
|
} |
||||||
|
|
||||||
|
if (imageBackground.getImage() != null) { |
||||||
|
previewPane.setImage(imageBackground.getImage()); |
||||||
|
} |
||||||
|
} else { |
||||||
|
previewPane.setImage(null); |
||||||
|
tiledRadioButton.setSelected(true); |
||||||
|
|
||||||
|
imageSizeLabel.setText(""); |
||||||
|
} |
||||||
|
|
||||||
|
fireChagneListener(); |
||||||
|
} |
||||||
|
|
||||||
|
public Background update() throws Exception { |
||||||
|
ImageBackground imageBackground = new ImageBackground(previewPane.getImage()); |
||||||
|
setImageStyle(); |
||||||
|
imageBackground.setLayout(imageStyle.getImageLayout()); |
||||||
|
return imageBackground; |
||||||
|
} |
||||||
|
|
||||||
|
public void addChangeListener(ChangeListener changeListener) { |
||||||
|
this.changeListener = changeListener; |
||||||
|
} |
||||||
|
|
||||||
|
private void fireChagneListener() { |
||||||
|
if (this.changeListener != null) { |
||||||
|
ChangeEvent evt = new ChangeEvent(this); |
||||||
|
this.changeListener.stateChanged(evt); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
ChangeListener imageSizeChangeListener = new ChangeListener() { |
||||||
|
|
||||||
|
public void stateChanged(ChangeEvent evt) { |
||||||
|
Image image = ((ImagePreviewPane) evt.getSource()).getImage(); |
||||||
|
|
||||||
|
if (image == null) { |
||||||
|
imageSizeLabel.setText(""); |
||||||
|
} else { |
||||||
|
imageSizeLabel.setText(Inter.getLocText(new String[]{"Size", "px"}, new String[]{": " + image.getWidth(null) + "x" + image.getHeight(null)})); |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
package com.fr.design.style.background.impl; |
||||||
|
|
||||||
|
import com.fr.stable.ArrayUtils; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 16/5/18. |
||||||
|
*/ |
||||||
|
public class ImageBackgroundPane4Browser extends ImageBackgroundPane { |
||||||
|
|
||||||
|
|
||||||
|
public ImageBackgroundPane4Browser() { |
||||||
|
super(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected JRadioButton[] imageLayoutButtons() { |
||||||
|
|
||||||
|
return (JRadioButton[]) ArrayUtils.addAll(super.imageLayoutButtons(), new JRadioButton[] { |
||||||
|
defaultRadioButton, |
||||||
|
tiledRadioButton, |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,39 @@ |
|||||||
|
package com.fr.design.style.background.impl; |
||||||
|
|
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.style.background.BackgroundDetailPane; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import com.fr.general.Background; |
||||||
|
import com.fr.general.Inter; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import javax.swing.event.ChangeListener; |
||||||
|
|
||||||
|
/** |
||||||
|
* Null background pane. |
||||||
|
*/ |
||||||
|
public class NullBackgroundPane extends BackgroundDetailPane { |
||||||
|
|
||||||
|
public NullBackgroundPane() { |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
|
||||||
|
UILabel centerLabel = new UILabel( |
||||||
|
Inter.getLocText("Background-Background_is_NULL") + "..."); |
||||||
|
this.add(centerLabel); |
||||||
|
centerLabel.setHorizontalAlignment(SwingConstants.CENTER); |
||||||
|
centerLabel.setBorder(BorderFactory.createLineBorder(GUICoreUtils.getTitleLineBorderColor())); |
||||||
|
} |
||||||
|
|
||||||
|
public void populate(Background background) { |
||||||
|
// do nothing.
|
||||||
|
} |
||||||
|
|
||||||
|
public Background update() throws Exception { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public void addChangeListener(ChangeListener changeListener) { |
||||||
|
// do nothing.
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,208 @@ |
|||||||
|
package com.fr.design.style.background.impl; |
||||||
|
|
||||||
|
import com.fr.base.GraphHelper; |
||||||
|
import com.fr.base.background.PatternBackground; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.style.color.ColorSelectBox; |
||||||
|
import com.fr.general.Background; |
||||||
|
import com.fr.general.Inter; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import javax.swing.event.ChangeEvent; |
||||||
|
import javax.swing.event.ChangeListener; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
import java.awt.geom.Rectangle2D; |
||||||
|
|
||||||
|
/** |
||||||
|
* Pattern background pane. |
||||||
|
*/ |
||||||
|
public class PatternBackgroundPane extends BPane { |
||||||
|
|
||||||
|
private int patternIndex = 0; // pattern setIndex.
|
||||||
|
protected ColorSelectBox foregroundColorPane; |
||||||
|
protected ColorSelectBox backgroundColorPane; |
||||||
|
private PatternButton[] patternButtonArray; |
||||||
|
|
||||||
|
public PatternBackgroundPane() { |
||||||
|
super(12); |
||||||
|
|
||||||
|
foregroundColorPane.addSelectChangeListener(colorChangeListener); |
||||||
|
backgroundColorPane.addSelectChangeListener(colorChangeListener); |
||||||
|
} |
||||||
|
|
||||||
|
public PatternBackgroundPane(int nColumn) { |
||||||
|
super(nColumn); |
||||||
|
|
||||||
|
if(foregroundColorPane != null) { |
||||||
|
foregroundColorPane.addSelectChangeListener(colorChangeListener); |
||||||
|
} |
||||||
|
if(backgroundColorPane != null) { |
||||||
|
backgroundColorPane.addSelectChangeListener(colorChangeListener); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
protected String titleOfTypePane() { |
||||||
|
return Inter.getLocText("Background-Pattern"); |
||||||
|
} |
||||||
|
protected LayoutManager layoutOfTypePane(int nColumn) { |
||||||
|
return FRGUIPaneFactory.createNColumnGridLayout(nColumn); |
||||||
|
} |
||||||
|
|
||||||
|
protected void setChildrenOfTypePane(JPanel typePane2) { |
||||||
|
ButtonGroup patternButtonGroup = new ButtonGroup(); |
||||||
|
patternButtonArray = new PatternButton[PatternBackground.PATTERN_COUNT]; |
||||||
|
for (int i = 0; i < PatternBackground.PATTERN_COUNT; i++) { |
||||||
|
patternButtonArray[i] = new PatternButton(i); |
||||||
|
patternButtonGroup.add(patternButtonArray[i]); |
||||||
|
typePane2.add(patternButtonArray[i]); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
protected void setChildrenOfContentPane(JPanel contentPane) { |
||||||
|
// colors
|
||||||
|
JPanel colorPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("Colors")); |
||||||
|
contentPane.add(colorPane); |
||||||
|
|
||||||
|
foregroundColorPane = new ColorSelectBox(80); |
||||||
|
backgroundColorPane = new ColorSelectBox(80); |
||||||
|
foregroundColorPane.setSelectObject(Color.lightGray); |
||||||
|
backgroundColorPane.setSelectObject(Color.black); |
||||||
|
|
||||||
|
colorPane.add(Box.createHorizontalStrut(2)); |
||||||
|
colorPane.add(this.createLabelColorPane(Inter.getLocText("Foreground") |
||||||
|
+ ":", foregroundColorPane)); |
||||||
|
|
||||||
|
colorPane.add(Box.createHorizontalStrut(8)); |
||||||
|
|
||||||
|
colorPane.add(this.createLabelColorPane(Inter.getLocText("Background") |
||||||
|
+ ":", backgroundColorPane)); |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createLabelColorPane(String text, |
||||||
|
ColorSelectBox colorPane) { |
||||||
|
JPanel labelColorPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); |
||||||
|
labelColorPane.add(new UILabel(text)); |
||||||
|
labelColorPane.add(colorPane); |
||||||
|
|
||||||
|
return labelColorPane; |
||||||
|
} |
||||||
|
|
||||||
|
public void populate(Background background) { |
||||||
|
if (background != null && background instanceof PatternBackground) { |
||||||
|
PatternBackground patternBackground = (PatternBackground) background; |
||||||
|
int patternIndex = patternBackground.getPatternIndex(); |
||||||
|
|
||||||
|
if (patternIndex >= 0 |
||||||
|
&& patternIndex < this.patternButtonArray.length) { |
||||||
|
this.patternButtonArray[patternIndex].setSelected(true); |
||||||
|
this.patternIndex = patternIndex; |
||||||
|
} else { |
||||||
|
this.patternIndex = 0; |
||||||
|
} |
||||||
|
|
||||||
|
foregroundColorPane.setSelectObject(patternBackground.getForeground()); |
||||||
|
backgroundColorPane.setSelectObject(patternBackground.getBackground()); |
||||||
|
} else { |
||||||
|
patternIndex = 0; |
||||||
|
this.patternButtonArray[0].setSelected(true); |
||||||
|
|
||||||
|
foregroundColorPane.setSelectObject(Color.lightGray); |
||||||
|
backgroundColorPane.setSelectObject(Color.black); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public Background update() throws Exception { |
||||||
|
return new PatternBackground(patternIndex, foregroundColorPane.getSelectObject(), backgroundColorPane.getSelectObject()); |
||||||
|
} |
||||||
|
|
||||||
|
public void addChangeListener(ChangeListener changeListener) { |
||||||
|
foregroundColorPane.addSelectChangeListener(changeListener); |
||||||
|
backgroundColorPane.addSelectChangeListener(changeListener); |
||||||
|
|
||||||
|
for (int i = 0; i < this.patternButtonArray.length; i++) { |
||||||
|
this.patternButtonArray[i].addChangeListener(changeListener); |
||||||
|
} |
||||||
|
} |
||||||
|
// Foreground or Background changed.
|
||||||
|
ChangeListener colorChangeListener = new ChangeListener() { |
||||||
|
|
||||||
|
public void stateChanged(ChangeEvent e) { |
||||||
|
for (int i = 0; i < patternButtonArray.length; i++) { |
||||||
|
patternButtonArray[i].setPatternForeground(foregroundColorPane.getSelectObject()); |
||||||
|
patternButtonArray[i].setPatternBackground(backgroundColorPane.getSelectObject()); |
||||||
|
} |
||||||
|
|
||||||
|
PatternBackgroundPane.this.repaint();// repaint
|
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Pattern type button. |
||||||
|
*/ |
||||||
|
class PatternButton extends JToggleButton implements ActionListener { |
||||||
|
|
||||||
|
public PatternButton(int pIndex) { |
||||||
|
this.pIndex = pIndex; |
||||||
|
this.addActionListener(this); |
||||||
|
|
||||||
|
this.setCursor(new Cursor(Cursor.HAND_CURSOR)); |
||||||
|
this.setBorder(null); |
||||||
|
this.patternBackground = new PatternBackground(this.pIndex, |
||||||
|
Color.lightGray, Color.black); |
||||||
|
} |
||||||
|
|
||||||
|
public void paintComponent(Graphics g) { |
||||||
|
Graphics2D g2d = (Graphics2D) g; |
||||||
|
|
||||||
|
Dimension d = getSize(); |
||||||
|
this.patternBackground.paint(g2d, new Rectangle2D.Double(0, 0, |
||||||
|
d.width - 1, d.height - 1)); |
||||||
|
|
||||||
|
if (this.pIndex == patternIndex) {// it's selected.
|
||||||
|
g2d.setPaint(new Color(255, 51, 0)); |
||||||
|
} else { |
||||||
|
g2d.setPaint(Color.gray); |
||||||
|
} |
||||||
|
GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1, |
||||||
|
d.height - 1)); |
||||||
|
} |
||||||
|
|
||||||
|
public Dimension getPreferredSize() { |
||||||
|
return new Dimension(24, 24); |
||||||
|
} |
||||||
|
|
||||||
|
public void setPatternForeground(Color foreground) { |
||||||
|
this.patternBackground.setForeground(foreground); |
||||||
|
} |
||||||
|
|
||||||
|
public void setPatternBackground(Color background) { |
||||||
|
this.patternBackground.setBackground(background); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* set Pattern setIndex. |
||||||
|
*/ |
||||||
|
public void actionPerformed(ActionEvent evt) { |
||||||
|
PatternBackgroundPane.this.patternIndex = pIndex; |
||||||
|
|
||||||
|
fireChagneListener(); |
||||||
|
PatternBackgroundPane.this.repaint();// repaint
|
||||||
|
} |
||||||
|
|
||||||
|
public void addChangeListener(ChangeListener changeListener) { |
||||||
|
this.changeListener = changeListener; |
||||||
|
} |
||||||
|
|
||||||
|
private void fireChagneListener() { |
||||||
|
if (this.changeListener != null) { |
||||||
|
ChangeEvent evt = new ChangeEvent(this); |
||||||
|
this.changeListener.stateChanged(evt); |
||||||
|
} |
||||||
|
} |
||||||
|
private int pIndex = 0; |
||||||
|
private PatternBackground patternBackground; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
package com.fr.design.style.background.impl; |
||||||
|
|
||||||
|
import com.fr.design.style.color.ColorSelectBox; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 16/5/18. |
||||||
|
*/ |
||||||
|
public class PatternBackgroundPaneNoFore extends PatternBackgroundPane { |
||||||
|
|
||||||
|
public PatternBackgroundPaneNoFore(int nColumn) { |
||||||
|
super(nColumn); |
||||||
|
} |
||||||
|
|
||||||
|
// 重载 不加载两个前后按钮
|
||||||
|
protected void setChildrenOfContentPane(JPanel contentPane) { |
||||||
|
foregroundColorPane = new ColorSelectBox(80); |
||||||
|
backgroundColorPane = new ColorSelectBox(80); |
||||||
|
foregroundColorPane.setSelectObject(Color.lightGray); |
||||||
|
backgroundColorPane.setSelectObject(Color.black); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,197 @@ |
|||||||
|
package com.fr.design.style.background.impl; |
||||||
|
|
||||||
|
import com.fr.base.GraphHelper; |
||||||
|
import com.fr.base.background.TextureBackground; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.general.Background; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
import com.fr.general.Inter; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import javax.swing.event.ChangeEvent; |
||||||
|
import javax.swing.event.ChangeListener; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
import java.awt.geom.Rectangle2D; |
||||||
|
|
||||||
|
/** |
||||||
|
* Texture background pane. TODO kunsnat: 拆出去. 真特么的长.. |
||||||
|
*/ |
||||||
|
public class TextureBackgroundPane extends BPane { |
||||||
|
|
||||||
|
private static final TexturePaint[] EMBED_TEXTURE_PAINT_ARRAY = new TexturePaint[]{ |
||||||
|
TextureBackground.NEWSPRINT_TEXTURE_PAINT, |
||||||
|
TextureBackground.RECYCLED_PAPER_TEXTURE_PAINT, |
||||||
|
TextureBackground.PARCHMENT_TEXTURE_PAINT, |
||||||
|
TextureBackground.STATIONERY_TEXTURE_PAINT, |
||||||
|
TextureBackground.GREEN_MARBLE_TEXTURE_PAINT, |
||||||
|
TextureBackground.WHITE_MARBLE_TEXTURE_PAINT, |
||||||
|
TextureBackground.BROWN_MARBLE_TEXTURE_PAINT, |
||||||
|
TextureBackground.GRANITE_TEXTURE_PAINT, |
||||||
|
TextureBackground.BLUE_TISSUE_PAPER_TEXTURE_PAINT, |
||||||
|
TextureBackground.PINK_TISSUE_PAPER_TEXTURE_PAINT, |
||||||
|
TextureBackground.PURPLE_MESH_TEXTURE_PAINT, |
||||||
|
TextureBackground.BOUQUET_TEXTURE_PAINT, |
||||||
|
TextureBackground.PAPYRUS_TEXTURE_PAINT, |
||||||
|
TextureBackground.CANVAS_TEXTURE_PAINT, |
||||||
|
TextureBackground.DENIM_TEXTURE_PAINT, |
||||||
|
TextureBackground.WOVEN_MAT_TEXTURE_PAINT, |
||||||
|
TextureBackground.WATER_DROPLETS_TEXTURE_PAINT, |
||||||
|
TextureBackground.PAPER_BAG_TEXTURE_PAINT, |
||||||
|
TextureBackground.FISH_FOSSIL_TEXTURE_PAINT, |
||||||
|
TextureBackground.SAND_TEXTURE_PAINT, |
||||||
|
TextureBackground.CORK_TEXTURE_PAINT, |
||||||
|
TextureBackground.WALNUT_TEXTURE_PAINT, |
||||||
|
TextureBackground.OAK_TEXTURE_PAINT, |
||||||
|
TextureBackground.MEDIUM_WOOD_TEXTURE_PAINT}; |
||||||
|
|
||||||
|
private static final String[] EMBED_TEXTURE_PAINT_DES_ARRAY = new String[]{ |
||||||
|
Inter.getLocText("BackgroundTexture-Newsprint"), |
||||||
|
Inter.getLocText("BackgroundTexture-RecycledPaper"), |
||||||
|
Inter.getLocText("BackgroundTexture-Parchment"), |
||||||
|
Inter.getLocText("BackgroundTexture-Stationery"), |
||||||
|
Inter.getLocText("BackgroundTexture-GreenMarble"), |
||||||
|
Inter.getLocText("BackgroundTexture-WhiteMarble"), |
||||||
|
Inter.getLocText("BackgroundTexture-BrownMarble"), |
||||||
|
Inter.getLocText("BackgroundTexture-Granite"), |
||||||
|
Inter.getLocText("BackgroundTexture-BlueTissuePaper"), |
||||||
|
Inter.getLocText("BackgroundTexture-PinkTissuePaper"), |
||||||
|
Inter.getLocText("BackgroundTexture-PurpleMesh"), |
||||||
|
Inter.getLocText("BackgroundTexture-Bouquet"), |
||||||
|
Inter.getLocText("BackgroundTexture-Papyrus"), |
||||||
|
Inter.getLocText("BackgroundTexture-Canvas"), |
||||||
|
Inter.getLocText("BackgroundTexture-Denim"), |
||||||
|
Inter.getLocText("BackgroundTexture-WovenMat"), |
||||||
|
Inter.getLocText("BackgroundTexture-WaterDroplets"), |
||||||
|
Inter.getLocText("BackgroundTexture-PaperBag"), |
||||||
|
Inter.getLocText("BackgroundTexture-FishFossil"), |
||||||
|
Inter.getLocText("BackgroundTexture-Sand"), |
||||||
|
Inter.getLocText("BackgroundTexture-Cork"), |
||||||
|
Inter.getLocText("BackgroundTexture-Walnut"), |
||||||
|
Inter.getLocText("BackgroundTexture-Oak"), |
||||||
|
Inter.getLocText("BackgroundTexture-MediumWood") |
||||||
|
}; |
||||||
|
|
||||||
|
private TexturePaint texturePaint; |
||||||
|
private TextureButton[] textureButtonArray; |
||||||
|
|
||||||
|
public TextureBackgroundPane() { |
||||||
|
super(8);// 默认的.
|
||||||
|
} |
||||||
|
|
||||||
|
public TextureBackgroundPane(int colum) { |
||||||
|
super(colum);// 自定义的.
|
||||||
|
} |
||||||
|
|
||||||
|
protected LayoutManager layoutOfTypePane(int nColumn) { |
||||||
|
return FRGUIPaneFactory.createNColumnGridLayout(nColumn); |
||||||
|
} |
||||||
|
|
||||||
|
protected String titleOfTypePane() { |
||||||
|
return Inter.getLocText("Background-Texture"); |
||||||
|
} |
||||||
|
protected void setChildrenOfTypePane(JPanel typePane2) { |
||||||
|
ButtonGroup patternButtonGroup = new ButtonGroup(); |
||||||
|
textureButtonArray = new TextureButton[EMBED_TEXTURE_PAINT_ARRAY.length]; |
||||||
|
for (int i = 0; i < EMBED_TEXTURE_PAINT_ARRAY.length; i++) { |
||||||
|
textureButtonArray[i] = new TextureButton( |
||||||
|
EMBED_TEXTURE_PAINT_ARRAY[i], EMBED_TEXTURE_PAINT_DES_ARRAY[i]); |
||||||
|
patternButtonGroup.add(textureButtonArray[i]); |
||||||
|
typePane2.add(textureButtonArray[i]); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void populate(Background background) { |
||||||
|
if (background instanceof TextureBackground) { |
||||||
|
TextureBackground textureBackground = (TextureBackground) background; |
||||||
|
|
||||||
|
this.texturePaint = textureBackground.getTexturePaint(); |
||||||
|
|
||||||
|
for (int i = 0; i < textureButtonArray.length; i++) { |
||||||
|
if (ComparatorUtils.equals(textureButtonArray[i].getTexturePaint(), this.texturePaint)) { |
||||||
|
textureButtonArray[i].setSelected(true); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
} else { |
||||||
|
this.textureButtonArray[0].setSelected(true); |
||||||
|
this.texturePaint = textureButtonArray[0].getTexturePaint(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public Background update() throws Exception { |
||||||
|
return new TextureBackground(this.texturePaint); |
||||||
|
} |
||||||
|
|
||||||
|
public void addChangeListener(ChangeListener changeListener) { |
||||||
|
for (int i = 0; i < this.textureButtonArray.length; i++) { |
||||||
|
this.textureButtonArray[i].addChangeListener(changeListener); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Texture type button. |
||||||
|
*/ |
||||||
|
class TextureButton extends JToggleButton implements ActionListener { |
||||||
|
|
||||||
|
private TexturePaint buttonTexturePaint; |
||||||
|
|
||||||
|
public TextureButton(TexturePaint buttonTexturePaint, String tooltip) { |
||||||
|
this.buttonTexturePaint = buttonTexturePaint; |
||||||
|
this.setToolTipText(tooltip); |
||||||
|
|
||||||
|
this.setCursor(new Cursor(Cursor.HAND_CURSOR)); |
||||||
|
this.addActionListener(this); |
||||||
|
this.setBorder(null); |
||||||
|
} |
||||||
|
|
||||||
|
public void paintComponent(Graphics g) { |
||||||
|
Graphics2D g2d = (Graphics2D) g; |
||||||
|
|
||||||
|
Dimension d = getSize(); |
||||||
|
|
||||||
|
g2d.setPaint(this.buttonTexturePaint); |
||||||
|
GraphHelper.fill(g2d, new Rectangle2D.Double(0, 0, d.width - 1, |
||||||
|
d.height - 1)); |
||||||
|
|
||||||
|
if (ComparatorUtils.equals(texturePaint, this.buttonTexturePaint)) {// it's
|
||||||
|
// selected.
|
||||||
|
g2d.setPaint(Color.black); |
||||||
|
} else { |
||||||
|
g2d.setPaint(Color.gray); |
||||||
|
} |
||||||
|
GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1, |
||||||
|
d.height - 1)); |
||||||
|
} |
||||||
|
|
||||||
|
public Dimension getPreferredSize() { |
||||||
|
return new Dimension(36, 32); |
||||||
|
} |
||||||
|
|
||||||
|
public TexturePaint getTexturePaint() { |
||||||
|
return this.buttonTexturePaint; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* set Pattern setIndex. |
||||||
|
*/ |
||||||
|
public void actionPerformed(ActionEvent evt) { |
||||||
|
TextureBackgroundPane.this.texturePaint = this.getTexturePaint(); |
||||||
|
|
||||||
|
fireChagneListener(); |
||||||
|
TextureBackgroundPane.this.repaint(); // repaint.
|
||||||
|
} |
||||||
|
|
||||||
|
public void addChangeListener(ChangeListener changeListener) { |
||||||
|
this.changeListener = changeListener; |
||||||
|
} |
||||||
|
|
||||||
|
private void fireChagneListener() { |
||||||
|
if (this.changeListener != null) { |
||||||
|
ChangeEvent evt = new ChangeEvent(this); |
||||||
|
this.changeListener.stateChanged(evt); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |