forked from fanruan/design
jinbokai
5 years ago
86 changed files with 2174 additions and 1390 deletions
@ -0,0 +1,77 @@ |
|||||||
|
package com.fr.design.os.impl; |
||||||
|
|
||||||
|
import com.fr.config.ServerPreferenceConfig; |
||||||
|
import com.fr.design.data.datapane.connect.ConnectionManagerPane; |
||||||
|
import com.fr.design.dcm.UniversalDatabaseOpener; |
||||||
|
import com.fr.design.dialog.BasicDialog; |
||||||
|
import com.fr.design.dialog.DialogActionAdapter; |
||||||
|
import com.fr.design.mainframe.DesignerContext; |
||||||
|
import com.fr.design.mainframe.DesignerFrame; |
||||||
|
import com.fr.file.ConnectionConfig; |
||||||
|
import com.fr.stable.os.OperatingSystem; |
||||||
|
import com.fr.stable.os.support.OSBasedAction; |
||||||
|
import com.fr.transaction.CallBackAdaptor; |
||||||
|
import com.fr.transaction.Configurations; |
||||||
|
import com.fr.transaction.WorkerFacade; |
||||||
|
import static com.fr.design.actions.server.ConnectionListAction.doWithDatasourceManager; |
||||||
|
|
||||||
|
/** |
||||||
|
* 数据连接窗口 |
||||||
|
* @author pengda |
||||||
|
* @date 2019/10/9 |
||||||
|
*/ |
||||||
|
public class DatabaseDialogAction implements OSBasedAction { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void execute(Object... objects) { |
||||||
|
if (ServerPreferenceConfig.getInstance().isUseUniverseDBM() && !OperatingSystem.isLinux()) { |
||||||
|
UniversalDatabaseOpener.showUniverseDatabaseDialog(); |
||||||
|
} else { |
||||||
|
openDesignDatabaseManager(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void openDesignDatabaseManager() { |
||||||
|
DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); |
||||||
|
final ConnectionConfig datasourceManager = ConnectionConfig.getInstance(); |
||||||
|
final ConnectionManagerPane databaseManagerPane = new ConnectionManagerPane() { |
||||||
|
public void complete() { |
||||||
|
ConnectionConfig connectionConfig = datasourceManager.mirror(); |
||||||
|
populate(connectionConfig); |
||||||
|
} |
||||||
|
|
||||||
|
protected void renameConnection(String oldName, String newName) { |
||||||
|
datasourceManager.renameConnection(oldName, newName); |
||||||
|
} |
||||||
|
}; |
||||||
|
final BasicDialog databaseListDialog = databaseManagerPane.showLargeWindow(designerFrame, null); |
||||||
|
databaseListDialog.addDialogActionListener(new DialogActionAdapter() { |
||||||
|
public void doOk() { |
||||||
|
if (!databaseManagerPane.isNamePermitted()) { |
||||||
|
databaseListDialog.setDoOKSucceed(false); |
||||||
|
return; |
||||||
|
} |
||||||
|
Configurations.modify(new WorkerFacade(ConnectionConfig.class) { |
||||||
|
@Override |
||||||
|
public void run() { |
||||||
|
databaseManagerPane.update(datasourceManager); |
||||||
|
} |
||||||
|
}.addCallBack(new CallBackAdaptor() { |
||||||
|
@Override |
||||||
|
public boolean beforeCommit() { |
||||||
|
//如果更新失败,则不关闭对话框,也不写xml文件,并且将对话框定位在请重命名的那个对象页面
|
||||||
|
return doWithDatasourceManager(datasourceManager, databaseManagerPane, databaseListDialog); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void afterCommit() { |
||||||
|
DesignerContext.getDesignerBean("databasename").refreshBeanElement(); |
||||||
|
} |
||||||
|
})); |
||||||
|
} |
||||||
|
}); |
||||||
|
databaseListDialog.setVisible(true); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,59 @@ |
|||||||
|
package com.fr.design.os.impl; |
||||||
|
|
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.stable.StableUtils; |
||||||
|
import com.fr.stable.os.OperatingSystem; |
||||||
|
import com.fr.stable.os.support.OSBasedAction; |
||||||
|
|
||||||
|
import java.io.IOException; |
||||||
|
/** |
||||||
|
* @author pengda |
||||||
|
* @date 2019/10/9 |
||||||
|
*/ |
||||||
|
public class DemoAction implements OSBasedAction { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void execute(Object... objects) { |
||||||
|
String installHome = StableUtils.getInstallHome(); |
||||||
|
if (installHome == null) { |
||||||
|
FineLoggerFactory.getLogger().error("Can not find the install home, please check it."); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
String executorPath; |
||||||
|
|
||||||
|
if (OperatingSystem.isMacos()) { |
||||||
|
executorPath = StableUtils.pathJoin(installHome, "bin", "designer.app"); |
||||||
|
} else if(OperatingSystem.isWindows()){ |
||||||
|
executorPath = StableUtils.pathJoin(installHome, "bin", "designer.exe demo"); |
||||||
|
}else{ |
||||||
|
executorPath = StableUtils.pathJoin(installHome, "bin", "designer.sh demo"); |
||||||
|
} |
||||||
|
|
||||||
|
if (OperatingSystem.isMacos()) { |
||||||
|
ProcessBuilder builder = new ProcessBuilder(); |
||||||
|
builder.command("open", "-a", executorPath, "--args", "demo"); |
||||||
|
try { |
||||||
|
builder.start(); |
||||||
|
} catch (IOException e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
} else if(OperatingSystem.isWindows()){ |
||||||
|
// ProcessBuilder这种方式在window下报错:系统找不到指定文件
|
||||||
|
Runtime rt = Runtime.getRuntime(); |
||||||
|
try { |
||||||
|
rt.exec(executorPath); |
||||||
|
} catch (IOException e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
}else{ |
||||||
|
//先用和win一样的方式
|
||||||
|
Runtime rt = Runtime.getRuntime(); |
||||||
|
try { |
||||||
|
rt.exec(executorPath); |
||||||
|
} catch (IOException e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,30 @@ |
|||||||
|
package com.fr.design.os.impl; |
||||||
|
|
||||||
|
import com.fr.config.ServerPreferenceConfig; |
||||||
|
import com.fr.design.extra.WebViewDlgHelper; |
||||||
|
import com.fr.design.upm.UpmFinder; |
||||||
|
import com.fr.design.utils.DesignUtils; |
||||||
|
import com.fr.stable.os.Arch; |
||||||
|
import com.fr.stable.os.OperatingSystem; |
||||||
|
import com.fr.stable.os.support.OSBasedAction; |
||||||
|
|
||||||
|
/** |
||||||
|
* 插件管理窗口 |
||||||
|
* @author pengda |
||||||
|
* @date 2019/10/9 |
||||||
|
*/ |
||||||
|
public class PMDialogAction implements OSBasedAction { |
||||||
|
private static String PLUGIN_MANAGER_ROUTE = "#management/plugin"; |
||||||
|
@Override |
||||||
|
public void execute(Object... objects) { |
||||||
|
if(Arch.getArch() == Arch.ARM){ |
||||||
|
DesignUtils.visitEnvServerByParameters( PLUGIN_MANAGER_ROUTE,null,null); |
||||||
|
return; |
||||||
|
} |
||||||
|
if (ServerPreferenceConfig.getInstance().isUseOptimizedUPM() && !OperatingSystem.isLinux()) { |
||||||
|
UpmFinder.showUPMDialog(); |
||||||
|
} else { |
||||||
|
WebViewDlgHelper.createPluginDialog(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,74 @@ |
|||||||
|
package com.fr.design.os.impl; |
||||||
|
|
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.stable.ArrayUtils; |
||||||
|
import com.fr.stable.StableUtils; |
||||||
|
import com.fr.stable.os.OperatingSystem; |
||||||
|
import com.fr.stable.os.support.OSBasedAction; |
||||||
|
import java.io.File; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
public class RestartAction implements OSBasedAction { |
||||||
|
@Override |
||||||
|
public void execute(Object... objects) { |
||||||
|
String[] filesToBeDelete = (String[])objects; |
||||||
|
String installHome = StableUtils.getInstallHome(); |
||||||
|
try{ |
||||||
|
if (OperatingSystem.isMacos()) { |
||||||
|
restartInMacOS(installHome, filesToBeDelete); |
||||||
|
} else if(OperatingSystem.isWindows()){ |
||||||
|
restartInWindows(installHome, filesToBeDelete); |
||||||
|
}else{ |
||||||
|
//增加一个Linux系统
|
||||||
|
restartInLinux(installHome,filesToBeDelete); |
||||||
|
} |
||||||
|
}catch(Exception e){ |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private static void restartInMacOS(String installHome, String[] filesToBeDelete) throws Exception { |
||||||
|
ProcessBuilder builder = new ProcessBuilder(); |
||||||
|
List<String> commands = new ArrayList<String>(); |
||||||
|
commands.add("open"); |
||||||
|
commands.add(installHome + File.separator + "bin" + File.separator + "restart.app"); |
||||||
|
if (ArrayUtils.isNotEmpty(filesToBeDelete)) { |
||||||
|
commands.add("--args"); |
||||||
|
commands.add(StableUtils.join(filesToBeDelete, "+")); |
||||||
|
} |
||||||
|
builder.command(commands); |
||||||
|
builder.start(); |
||||||
|
} |
||||||
|
|
||||||
|
private static void restartInWindows(String installHome, String[] filesToBeDelete) throws Exception { |
||||||
|
ProcessBuilder builder = new ProcessBuilder(); |
||||||
|
List<String> commands = new ArrayList<String>(); |
||||||
|
commands.add(installHome + File.separator + "bin" + File.separator + "restart.exe"); |
||||||
|
if (ArrayUtils.isNotEmpty(filesToBeDelete)) { |
||||||
|
commands.add(StableUtils.join(filesToBeDelete, "+")); |
||||||
|
} |
||||||
|
builder.command(commands); |
||||||
|
builder.start(); |
||||||
|
} |
||||||
|
|
||||||
|
private static void restartInLinux(String installHome, String[] filesToBeDelete) throws Exception { |
||||||
|
ProcessBuilder builder = new ProcessBuilder(); |
||||||
|
List<String> commands = new ArrayList<String>(); |
||||||
|
//现在先写的是restart.sh
|
||||||
|
commands.add(installHome + File.separator + "bin" + File.separator + "restart.sh"); |
||||||
|
if (ArrayUtils.isNotEmpty(filesToBeDelete)) { |
||||||
|
commands.add(StableUtils.join(filesToBeDelete, "+")); |
||||||
|
} |
||||||
|
builder.command(commands); |
||||||
|
builder.start(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,63 @@ |
|||||||
|
package com.fr.design.os.impl; |
||||||
|
|
||||||
|
import com.fr.base.FRContext; |
||||||
|
import com.fr.general.GeneralContext; |
||||||
|
import com.fr.stable.os.Arch; |
||||||
|
import com.fr.stable.os.OperatingSystem; |
||||||
|
import com.fr.stable.os.support.SupportOS; |
||||||
|
import com.fr.workspace.WorkContext; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author pengda |
||||||
|
* @date 2019/10/9 |
||||||
|
*/ |
||||||
|
public enum SupportOSImpl implements SupportOS { |
||||||
|
|
||||||
|
/** |
||||||
|
* ARM下屏蔽登录 |
||||||
|
*/ |
||||||
|
USERINFOPANE{ |
||||||
|
public boolean support(){ |
||||||
|
return Arch.getArch() != Arch.ARM; |
||||||
|
} |
||||||
|
}, |
||||||
|
/** |
||||||
|
* Linux系统屏蔽透明度 |
||||||
|
*/ |
||||||
|
OPACITY{ |
||||||
|
public boolean support(){ |
||||||
|
return !OperatingSystem.isLinux(); |
||||||
|
} |
||||||
|
}, |
||||||
|
/** |
||||||
|
* Linux系统屏蔽FineUI选项 |
||||||
|
*/ |
||||||
|
FINEUI{ |
||||||
|
public boolean support(){ |
||||||
|
return !OperatingSystem.isLinux(); |
||||||
|
} |
||||||
|
}, |
||||||
|
/** |
||||||
|
* 自动更新推送 |
||||||
|
*/ |
||||||
|
AUTOPUSHUPDATE{ |
||||||
|
@Override |
||||||
|
public boolean support() { |
||||||
|
boolean isLocalEnv = WorkContext.getCurrent().isLocal(); |
||||||
|
boolean isChineseEnv = GeneralContext.isChineseEnv(); |
||||||
|
boolean isLinux = OperatingSystem.isLinux(); |
||||||
|
// 远程设计和非中文环境以及Linux环境,都不生效
|
||||||
|
return isLocalEnv && isChineseEnv && !isLinux; |
||||||
|
} |
||||||
|
}, |
||||||
|
/** |
||||||
|
* BBS窗口 |
||||||
|
*/ |
||||||
|
BBSDIALOG{ |
||||||
|
@Override |
||||||
|
public boolean support() { |
||||||
|
return FRContext.isChineseEnv() && !OperatingSystem.isMacos() && Arch.getArch() != Arch.ARM; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
package com.fr.design.os.impl; |
||||||
|
|
||||||
|
import com.fr.design.mainframe.DesignerContext; |
||||||
|
import com.fr.design.update.ui.dialog.UpdateMainDialog; |
||||||
|
import com.fr.design.utils.DesignUtils; |
||||||
|
import com.fr.stable.os.OperatingSystem; |
||||||
|
import com.fr.stable.os.support.OSBasedAction; |
||||||
|
|
||||||
|
/** |
||||||
|
* 更新升级窗口 |
||||||
|
* @author pengda |
||||||
|
* @date 2019/10/9 |
||||||
|
*/ |
||||||
|
public class UpdateDialogAction implements OSBasedAction { |
||||||
|
private static String UPDATE_ROUTE = "#management/backup"; |
||||||
|
@Override |
||||||
|
public void execute(Object... objects) { |
||||||
|
if(!OperatingSystem.isLinux()) { |
||||||
|
UpdateMainDialog dialog = new UpdateMainDialog(DesignerContext.getDesignerFrame()); |
||||||
|
dialog.showDialog(); |
||||||
|
}else{ |
||||||
|
DesignUtils.visitEnvServerByParameters( UPDATE_ROUTE,null,null); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,80 @@ |
|||||||
|
package com.fr.design.update.actions; |
||||||
|
|
||||||
|
import com.fr.decision.update.backup.Recover; |
||||||
|
import com.fr.decision.update.data.UpdateConstants; |
||||||
|
import com.fr.decision.update.exception.UpdateException; |
||||||
|
import com.fr.general.CommonIOUtils; |
||||||
|
import com.fr.general.GeneralUtils; |
||||||
|
import com.fr.general.IOUtils; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.stable.CommonUtils; |
||||||
|
import com.fr.stable.StableUtils; |
||||||
|
import com.fr.stable.project.ProjectConstants; |
||||||
|
import com.fr.workspace.WorkContext; |
||||||
|
|
||||||
|
import java.io.File; |
||||||
|
import java.io.IOException; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Bryant |
||||||
|
* @version 10.0 |
||||||
|
* Created by Bryant on 2019-10-09 |
||||||
|
*/ |
||||||
|
public class RecoverForDesigner implements Recover { |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean recover() { |
||||||
|
try{ |
||||||
|
CommonIOUtils.copyFilesInDirByPath(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNERBACKUPPATH), |
||||||
|
StableUtils.pathJoin(StableUtils.getInstallHome(), ProjectConstants.LIB_NAME)); |
||||||
|
return true; |
||||||
|
} catch (IOException e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage() + "Recover error for designer"); |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean backup() { |
||||||
|
String installHome = StableUtils.getInstallHome(); |
||||||
|
//jar包备份文件的目录为"backup/"+jar包当前版本号
|
||||||
|
String todayBackupDir = StableUtils.pathJoin(installHome, UpdateConstants.DESIGNER_BACKUP_DIR, (GeneralUtils.readBuildNO())); |
||||||
|
backupFilesFromInstallEnv(todayBackupDir); |
||||||
|
backupFilesFromInstallLib(installHome, todayBackupDir); |
||||||
|
try { |
||||||
|
File file = new File(StableUtils.pathJoin(installHome, UpdateConstants.DOWNLOADPATH)); |
||||||
|
CommonUtils.mkdirs(file); |
||||||
|
IOUtils.copyFilesInDirByPath(StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME), |
||||||
|
StableUtils.pathJoin(installHome, UpdateConstants.DESIGNERBACKUPPATH)); |
||||||
|
return true; |
||||||
|
}catch (IOException e) { |
||||||
|
UpdateException exception = new UpdateException("Backup Exception for designer" + e.getMessage()); |
||||||
|
FineLoggerFactory.getLogger().error(exception.getMessage(),exception); |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void backupFilesFromInstallEnv(String todayBackupDir) { |
||||||
|
try { |
||||||
|
CommonUtils.mkdirs(new File(StableUtils.pathJoin(todayBackupDir,UpdateConstants.BACKUPPATH))); |
||||||
|
IOUtils.copyFilesInDirByPath( |
||||||
|
StableUtils.pathJoin(WorkContext.getCurrent().getPath(),ProjectConstants.LIB_NAME), |
||||||
|
StableUtils.pathJoin(todayBackupDir,UpdateConstants.BACKUPPATH)); |
||||||
|
} catch (IOException e) { |
||||||
|
UpdateException exception = new UpdateException(e.getMessage()); |
||||||
|
FineLoggerFactory.getLogger().error(exception.getMessage() + "backup for Designer recover in env failed"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void backupFilesFromInstallLib(String installHome, String todayBackupDir) { |
||||||
|
try { |
||||||
|
CommonUtils.mkdirs(new File(StableUtils.pathJoin(todayBackupDir,UpdateConstants.DESIGNERBACKUPPATH))); |
||||||
|
IOUtils.copyFilesInDirByPath( |
||||||
|
StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME), |
||||||
|
StableUtils.pathJoin(todayBackupDir,UpdateConstants.DESIGNERBACKUPPATH)); |
||||||
|
} catch (IOException e) { |
||||||
|
UpdateException exception = new UpdateException(e.getMessage()); |
||||||
|
FineLoggerFactory.getLogger().error(exception.getMessage() + "backup for Designer recover in install failed"); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -1,56 +0,0 @@ |
|||||||
package com.fr.design.update.domain; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by XINZAI on 2018/8/21. |
|
||||||
*/ |
|
||||||
|
|
||||||
|
|
||||||
import java.awt.Color; |
|
||||||
import java.util.Arrays; |
|
||||||
import java.util.Collections; |
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
/** |
|
||||||
* 更新升级的常量 |
|
||||||
*/ |
|
||||||
public interface UpdateConstants { |
|
||||||
|
|
||||||
String APPS_FOLDER_NAME = "webapps"; |
|
||||||
|
|
||||||
int CONNECTION_TIMEOUT = 1000 * 5; |
|
||||||
Color BAR_COLOR = new Color(0x3384F0); |
|
||||||
|
|
||||||
String CHANGELOG_X_START = "2018-07-11"; |
|
||||||
|
|
||||||
String DEFAULT_APP_NAME = "FineReport"; |
|
||||||
String DESIGNER_BACKUP_DIR = "designerbackup"; |
|
||||||
|
|
||||||
String UPDATE_CACHE_CONFIG_X = "updateCacheConfig10"; |
|
||||||
String UPDATE_CACHE_INFO_X = "updateCacheInfo10"; |
|
||||||
|
|
||||||
String JXBROWSER = "jxbrowser"; |
|
||||||
|
|
||||||
List<String> JARS_FOR_SERVER_X = Collections.unmodifiableList(Arrays.asList(new String[]{ |
|
||||||
"fine-activator-10.0.jar", |
|
||||||
"fine-core-10.0.jar", |
|
||||||
"fine-report-engine-10.0.jar", |
|
||||||
"fine-decision-10.0.jar", |
|
||||||
"fine-decision-report-10.0.jar", |
|
||||||
"fine-schedule-10.0.jar", |
|
||||||
"fine-schedule-report-10.0.jar", |
|
||||||
"fine-swift-log-adaptor-10.0.jar", |
|
||||||
"fine-webui-10.0.jar", |
|
||||||
"fine-datasource-10.0.jar", |
|
||||||
"fine-third-10.0.jar", |
|
||||||
"fine-accumulator-10.0.jar" |
|
||||||
})); |
|
||||||
|
|
||||||
List<String> JARS_FOR_DESIGNER_X = Collections.unmodifiableList(Arrays.asList(new String[]{ |
|
||||||
"fine-report-designer-10.0.jar", |
|
||||||
"aspectjrt.jar" |
|
||||||
})); |
|
||||||
List<String> LOG_TYPE = Collections.unmodifiableList(Arrays.asList(new String[]{ |
|
||||||
"REPORT", "MOBILE", "CHART", "PFC", "BI" |
|
||||||
})); |
|
||||||
|
|
||||||
} |
|
@ -1,46 +1,13 @@ |
|||||||
package com.fr.start; |
package com.fr.start; |
||||||
|
|
||||||
|
import com.fr.design.os.impl.DemoAction; |
||||||
import com.fr.log.FineLoggerFactory; |
import com.fr.stable.os.support.OSBasedAction; |
||||||
import com.fr.stable.OperatingSystem; |
import com.fr.stable.os.support.OSSupportCenter; |
||||||
import com.fr.stable.StableUtils; |
|
||||||
|
|
||||||
import java.io.IOException; |
|
||||||
|
|
||||||
public class Demo { |
public class Demo { |
||||||
public static void main(String[] args) { |
public static void main(String[] args) { |
||||||
String installHome = StableUtils.getInstallHome(); |
OSBasedAction osBasedAction = OSSupportCenter.getAction(DemoAction.class); |
||||||
if (installHome == null) { |
osBasedAction.execute(); |
||||||
FineLoggerFactory.getLogger().error("Can not find the install home, please check it."); |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
String executorPath; |
|
||||||
|
|
||||||
if (OperatingSystem.isMacOS()) { |
|
||||||
executorPath = StableUtils.pathJoin(installHome, "bin", "designer.app"); |
|
||||||
} else { |
|
||||||
executorPath = StableUtils.pathJoin(installHome, "bin", "designer.exe demo"); |
|
||||||
} |
|
||||||
|
|
||||||
if (OperatingSystem.isMacOS()) { |
|
||||||
ProcessBuilder builder = new ProcessBuilder(); |
|
||||||
builder.command("open", "-a", executorPath, "--args", "demo"); |
|
||||||
try { |
|
||||||
builder.start(); |
|
||||||
} catch (IOException e) { |
|
||||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
||||||
} |
|
||||||
} else { |
|
||||||
// ProcessBuilder这种方式在window下报错:系统找不到指定文件
|
|
||||||
Runtime rt = Runtime.getRuntime(); |
|
||||||
try { |
|
||||||
rt.exec(executorPath); |
|
||||||
} catch (IOException e) { |
|
||||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
System.exit(0); |
System.exit(0); |
||||||
} |
} |
||||||
} |
} |
@ -0,0 +1,98 @@ |
|||||||
|
package com.fr.design.chartx.component; |
||||||
|
|
||||||
|
import com.fr.chartx.data.field.ColumnField; |
||||||
|
import com.fr.chartx.data.field.DataFilterProperties; |
||||||
|
import com.fr.chartx.data.field.SeriesValueCorrelationDefinition; |
||||||
|
import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||||
|
import com.fr.van.chart.map.designer.VanChartGroupPane; |
||||||
|
|
||||||
|
import javax.swing.JPanel; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author shine |
||||||
|
* @version 10.0 |
||||||
|
* Created by shine on 2019/9/26 |
||||||
|
*/ |
||||||
|
public class CategorySeriesFilterPane extends JPanel { |
||||||
|
|
||||||
|
private AbstractSingleFilterPane seriesFilterPane; |
||||||
|
private AbstractSingleFilterPane categoryFilterPane; |
||||||
|
|
||||||
|
public CategorySeriesFilterPane() { |
||||||
|
seriesFilterPane = new AbstractSingleFilterPane() { |
||||||
|
@Override |
||||||
|
public String title4PopupWindow() { |
||||||
|
return Toolkit.i18nText("Fine-Design_Chart_Series"); |
||||||
|
} |
||||||
|
}; |
||||||
|
categoryFilterPane = new AbstractSingleFilterPane() { |
||||||
|
@Override |
||||||
|
public String title4PopupWindow() { |
||||||
|
return Toolkit.i18nText("Fine-Design_Chart_Style_Category"); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
JPanel groupPane = new VanChartGroupPane(new String[]{seriesFilterPane.title4PopupWindow(), categoryFilterPane.title4PopupWindow()} |
||||||
|
, new JPanel[]{seriesFilterPane, categoryFilterPane}) { |
||||||
|
}; |
||||||
|
|
||||||
|
JPanel contentPane = new JPanel(new BorderLayout()); |
||||||
|
contentPane.add(new JPanel(), BorderLayout.NORTH); |
||||||
|
contentPane.add(groupPane, BorderLayout.CENTER); |
||||||
|
|
||||||
|
this.setLayout(new BorderLayout()); |
||||||
|
this.add(TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), contentPane), BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
public void populateMultiCategoryFieldCollection(MultiCategoryColumnFieldCollection fieldCollection) { |
||||||
|
|
||||||
|
SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = fieldCollection.getSeriesValueCorrelationDefinition(); |
||||||
|
if (seriesValueCorrelationDefinition != null) { |
||||||
|
populateSeries(seriesValueCorrelationDefinition.getFilterProperties()); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
List<ColumnField> categoryList = fieldCollection.getCategoryList(); |
||||||
|
if (!categoryList.isEmpty()) { |
||||||
|
populateCategory(categoryList.get(0).getFilterProperties()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void updateMultiCategoryFieldCollection(MultiCategoryColumnFieldCollection fieldCollection) { |
||||||
|
|
||||||
|
SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = fieldCollection.getSeriesValueCorrelationDefinition(); |
||||||
|
if (seriesValueCorrelationDefinition != null) { |
||||||
|
seriesValueCorrelationDefinition.setFilterProperties(updateSeries()); |
||||||
|
} |
||||||
|
|
||||||
|
List<ColumnField> categoryList = fieldCollection.getCategoryList(); |
||||||
|
if (!categoryList.isEmpty()) { |
||||||
|
categoryList.get(0).setFilterProperties(updateCategory()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void populateSeries(DataFilterProperties series) { |
||||||
|
seriesFilterPane.populateBean(series); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private void populateCategory(DataFilterProperties category) { |
||||||
|
categoryFilterPane.populateBean(category); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private DataFilterProperties updateSeries() { |
||||||
|
return seriesFilterPane.updateBean(); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private DataFilterProperties updateCategory() { |
||||||
|
return categoryFilterPane.updateBean(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -1,29 +0,0 @@ |
|||||||
package com.fr.van.chart.bubble; |
|
||||||
|
|
||||||
import com.fr.chart.chartattr.Plot; |
|
||||||
|
|
||||||
import com.fr.plugin.chart.base.VanChartConstants; |
|
||||||
import com.fr.plugin.chart.bubble.VanChartBubblePlot; |
|
||||||
import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by Mitisky on 16/3/31. |
|
||||||
*/ |
|
||||||
public class VanChartBubbleInteractivePane extends VanChartInteractivePaneWithOutSort { |
|
||||||
protected String[] getNameArray() { |
|
||||||
Plot plot = chart.getPlot(); |
|
||||||
if(plot instanceof VanChartBubblePlot && ((VanChartBubblePlot) plot).isForceBubble()) { |
|
||||||
return new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_XY_Axis"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")}; |
|
||||||
} |
|
||||||
return super.getNameArray(); |
|
||||||
} |
|
||||||
|
|
||||||
protected String[] getValueArray() { |
|
||||||
Plot plot = chart.getPlot(); |
|
||||||
if(plot instanceof VanChartBubblePlot && ((VanChartBubblePlot) plot).isForceBubble()) { |
|
||||||
return new String[]{VanChartConstants.ZOOM_TYPE_XY, VanChartConstants.ZOOM_TYPE_NONE}; |
|
||||||
} |
|
||||||
return super.getValueArray(); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -0,0 +1,85 @@ |
|||||||
|
package com.fr.van.chart.designer.component; |
||||||
|
|
||||||
|
import com.fr.base.FRContext; |
||||||
|
import com.fr.base.GraphHelper; |
||||||
|
import com.fr.base.ScreenResolution; |
||||||
|
import com.fr.design.gui.icombobox.UIComboBox; |
||||||
|
import com.fr.design.gui.icombobox.UIComboBoxRenderer; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.general.FRFont; |
||||||
|
import com.fr.plugin.chart.type.LineType; |
||||||
|
import com.fr.stable.Constants; |
||||||
|
|
||||||
|
import javax.swing.JLabel; |
||||||
|
import javax.swing.JList; |
||||||
|
import java.awt.Component; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.Font; |
||||||
|
import java.awt.FontMetrics; |
||||||
|
import java.awt.Graphics; |
||||||
|
import java.awt.Graphics2D; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by shine on 2019/08/30. |
||||||
|
*/ |
||||||
|
public class LineTypeComboBox extends UIComboBox { |
||||||
|
|
||||||
|
public LineTypeComboBox(LineType[] lineType) { |
||||||
|
super(lineType); |
||||||
|
|
||||||
|
this.setRenderer(new CellRenderer()); |
||||||
|
} |
||||||
|
|
||||||
|
private static class CellRenderer extends UIComboBoxRenderer { |
||||||
|
|
||||||
|
private LineType lineType; |
||||||
|
|
||||||
|
public Component getListCellRendererComponent( |
||||||
|
JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||||||
|
|
||||||
|
JLabel comp = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||||||
|
this.lineType = (LineType) value; |
||||||
|
comp.setText(null); |
||||||
|
return comp; |
||||||
|
} |
||||||
|
|
||||||
|
public void paint(Graphics g) { |
||||||
|
super.paint(g); |
||||||
|
Graphics2D g2d = (Graphics2D) g; |
||||||
|
|
||||||
|
Dimension d = getSize(); |
||||||
|
g2d.setColor(getForeground()); |
||||||
|
|
||||||
|
switch (this.lineType) { |
||||||
|
case NONE: |
||||||
|
FRFont font = FRContext.getDefaultValues().getFRFont(); |
||||||
|
int resolution = ScreenResolution.getScreenResolution(); |
||||||
|
Font rfont = font.applyResolutionNP(resolution); |
||||||
|
g2d.setFont(rfont); |
||||||
|
FontMetrics fm = GraphHelper.getFontMetrics(rfont); |
||||||
|
GraphHelper.drawString(g2d, Toolkit.i18nText("Fine-Design_Report_None"), 4, (d.height - fm.getHeight()) / 2 + fm.getAscent()); |
||||||
|
break; |
||||||
|
case NORMAL: |
||||||
|
GraphHelper.drawLine(g2d, 4, d.height / 2, d.width - 8, d.height / 2); |
||||||
|
break; |
||||||
|
case DASH: |
||||||
|
GraphHelper.drawLine(g2d, 4, d.height / 2, d.width - 8, d.height / 2, Constants.LINE_DASH); |
||||||
|
break; |
||||||
|
default: |
||||||
|
break; |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public Dimension getPreferredSize() { |
||||||
|
return new Dimension(60, 16); |
||||||
|
} |
||||||
|
|
||||||
|
public Dimension getMinimumSize() { |
||||||
|
return getPreferredSize(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -1,30 +1,17 @@ |
|||||||
package com.fr.van.chart.designer.component; |
package com.fr.van.chart.designer.component; |
||||||
|
|
||||||
import com.fr.design.gui.ilable.UILabel; |
|
||||||
import com.fr.design.layout.TableLayoutHelper; |
|
||||||
|
|
||||||
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
|
||||||
|
|
||||||
import javax.swing.JPanel; |
|
||||||
import java.awt.Component; |
import java.awt.Component; |
||||||
|
|
||||||
/** |
/** |
||||||
* 线-线型 |
* 线型+线宽+空值断开 |
||||||
*/ |
*/ |
||||||
public class VanChartLineWidthPane extends VanChartLineTypePane { |
public class VanChartLineWidthPane extends VanChartLineTypePane { |
||||||
private static final long serialVersionUID = 4537158946119294689L; |
private static final long serialVersionUID = 4537158946119294689L; |
||||||
|
|
||||||
protected JPanel createContentPane(double p, double f) { |
@Override |
||||||
double[] row = {p, p, p}; |
protected Component[][] createContentComponent(Component[] lineStyleComponent, Component[] nullValueBreakComponent) { |
||||||
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
return new Component[][]{ |
||||||
double[] col = {f, e}; |
nullValueBreakComponent |
||||||
|
|
||||||
Component[][] components = new Component[][]{ |
|
||||||
new Component[]{null,null}, |
|
||||||
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Style")), lineWidth}, |
|
||||||
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Null_Value_Break")), nullValueBreak}, |
|
||||||
}; |
}; |
||||||
|
|
||||||
return TableLayoutHelper.createTableLayoutPane(components, row, col); |
|
||||||
} |
} |
||||||
} |
} |
@ -1,19 +1,15 @@ |
|||||||
package com.fr.van.chart.designer.other; |
package com.fr.van.chart.designer.other; |
||||||
|
|
||||||
import com.fr.plugin.chart.attr.plot.VanChartPlot; |
import com.fr.van.chart.designer.other.zoom.MapZoomPane; |
||||||
|
import com.fr.van.chart.designer.other.zoom.ZoomPane; |
||||||
import javax.swing.JPanel; |
|
||||||
import java.awt.BorderLayout; |
|
||||||
|
|
||||||
/** |
/** |
||||||
* Created by mengao on 2017/4/7. |
* Created by mengao on 2017/4/7. |
||||||
*/ |
*/ |
||||||
public class VanChartInteractivePaneWithMapZoom extends VanChartInteractivePaneWithOutSort { |
public class VanChartInteractivePaneWithMapZoom extends VanChartInteractivePaneWithOutSort { |
||||||
|
|
||||||
@Override |
@Override |
||||||
protected JPanel createZoomPaneContent(JPanel zoomWidgetPane, JPanel zoomGesturePane, JPanel changeEnablePane, JPanel zoomTypePane, VanChartPlot plot) { |
protected ZoomPane createZoomPane() { |
||||||
JPanel panel = new JPanel(new BorderLayout(0, 4)); |
return new MapZoomPane(); |
||||||
panel.add(zoomWidgetPane, BorderLayout.NORTH); |
|
||||||
panel.add(zoomGesturePane, BorderLayout.CENTER); |
|
||||||
return panel; |
|
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -0,0 +1,47 @@ |
|||||||
|
package com.fr.van.chart.designer.other.zoom; |
||||||
|
|
||||||
|
import com.fr.chartx.attr.ZoomAttribute; |
||||||
|
import com.fr.design.gui.ibutton.UIButtonGroup; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
|
||||||
|
import java.awt.Component; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by shine on 2019/08/28. |
||||||
|
*/ |
||||||
|
public class MapZoomPane extends ZoomPane { |
||||||
|
|
||||||
|
private UIButtonGroup<Boolean> mapZoomWidget;//地图缩放控件
|
||||||
|
private UIButtonGroup<Boolean> gestureZoomGroup;//地图手势缩放
|
||||||
|
|
||||||
|
@Override |
||||||
|
protected Component[][] getSouthComps() { |
||||||
|
mapZoomWidget = new UIButtonGroup<Boolean>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Open") |
||||||
|
, Toolkit.i18nText("Fine-Design_Chart_Close")}, new Boolean[]{true, false}); |
||||||
|
|
||||||
|
gestureZoomGroup = new UIButtonGroup<Boolean>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Open") |
||||||
|
, Toolkit.i18nText("Fine-Design_Chart_Close")}, new Boolean[]{true, false}); |
||||||
|
|
||||||
|
|
||||||
|
return new Component[][]{ |
||||||
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Zoom_Widget")), mapZoomWidget}, |
||||||
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_ZoomGesture")), gestureZoomGroup} |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(ZoomAttribute ob) { |
||||||
|
super.populateBean(ob); |
||||||
|
mapZoomWidget.setSelectedItem(ob.isMapZoomWidget()); |
||||||
|
gestureZoomGroup.setSelectedItem(ob.isGestureZoom()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ZoomAttribute updateBean() { |
||||||
|
ZoomAttribute zoomAttribute = super.updateBean(); |
||||||
|
zoomAttribute.setMapZoomWidget(mapZoomWidget.getSelectedItem()); |
||||||
|
zoomAttribute.setGestureZoom(gestureZoomGroup.getSelectedItem()); |
||||||
|
return zoomAttribute; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,224 @@ |
|||||||
|
package com.fr.van.chart.designer.other.zoom; |
||||||
|
|
||||||
|
import com.fr.chartx.attr.ZoomAttribute; |
||||||
|
import com.fr.chartx.attr.ZoomInitialDisplayType; |
||||||
|
import com.fr.chartx.attr.ZoomModeType; |
||||||
|
import com.fr.design.beans.BasicBeanPane; |
||||||
|
import com.fr.design.formula.TinyFormulaPane; |
||||||
|
import com.fr.design.gui.ibutton.UIButtonGroup; |
||||||
|
import com.fr.design.gui.icombobox.UIComboBox; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.gui.ispinner.UISpinner; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.TableLayout; |
||||||
|
import com.fr.extended.chart.StringFormula; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||||
|
|
||||||
|
import javax.swing.BorderFactory; |
||||||
|
import javax.swing.JPanel; |
||||||
|
import javax.swing.event.ChangeEvent; |
||||||
|
import javax.swing.event.ChangeListener; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.CardLayout; |
||||||
|
import java.awt.Component; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
import java.util.Arrays; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by shine on 2019/08/28. |
||||||
|
*/ |
||||||
|
public class ZoomPane extends BasicBeanPane<ZoomAttribute> { |
||||||
|
|
||||||
|
private UIButtonGroup<ZoomModeType> modeTypeButtonGroup; |
||||||
|
|
||||||
|
private JPanel customModePane; |
||||||
|
private UIComboBox initialDisplayTypeComboBox; |
||||||
|
private JPanel initialDisplayCardPane; |
||||||
|
private UISpinner topCategorySpinner; |
||||||
|
private TinyFormulaPane leftFormulaPane; |
||||||
|
private TinyFormulaPane rightFormulaPane; |
||||||
|
|
||||||
|
private UIButtonGroup<Boolean> selectionZoomGroup; |
||||||
|
|
||||||
|
public ZoomPane() { |
||||||
|
initComponent(); |
||||||
|
} |
||||||
|
|
||||||
|
private void initComponent() { |
||||||
|
|
||||||
|
double f = TableLayout.FILL; |
||||||
|
double e = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH; |
||||||
|
double p = TableLayout.PREFERRED; |
||||||
|
double[] columnSize = {f, e}; |
||||||
|
|
||||||
|
JPanel northPane = createNorthPane(f, p); |
||||||
|
|
||||||
|
initCustomModePane(columnSize, p); |
||||||
|
|
||||||
|
JPanel southPane = createSouthPane(f, p); |
||||||
|
|
||||||
|
this.setLayout(new BorderLayout(0, 6)); |
||||||
|
|
||||||
|
if (northPane != null) { |
||||||
|
this.add(northPane, BorderLayout.NORTH); |
||||||
|
} |
||||||
|
if (customModePane != null) { |
||||||
|
this.add(customModePane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
if (southPane != null) { |
||||||
|
this.add(southPane, BorderLayout.SOUTH); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
protected JPanel createNorthPane(double f, double p) { |
||||||
|
modeTypeButtonGroup = new UIButtonGroup<ZoomModeType>(new String[]{ |
||||||
|
Toolkit.i18nText("Fine-Design_Chart_Mode_Auto"), |
||||||
|
Toolkit.i18nText("Fine-Design_Chart_Mode_Custom"), |
||||||
|
Toolkit.i18nText("Fine-Design_Chart_Close") |
||||||
|
}, new ZoomModeType[]{ZoomModeType.AUTO, ZoomModeType.CUSTOM, ZoomModeType.CLOSE}); |
||||||
|
|
||||||
|
modeTypeButtonGroup.addChangeListener(new ChangeListener() { |
||||||
|
@Override |
||||||
|
public void stateChanged(ChangeEvent e) { |
||||||
|
checkCustomModePane(); |
||||||
|
} |
||||||
|
}); |
||||||
|
Component[][] components = new Component[][]{ |
||||||
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Zoom_Mode_type")), modeTypeButtonGroup} |
||||||
|
}; |
||||||
|
return TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p} |
||||||
|
, new double[]{f, TableLayout4VanChartHelper.EDIT_AREA_WIDTH}); |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createSouthPane(double f, double p) { |
||||||
|
|
||||||
|
Component[][] components = getSouthComps(); |
||||||
|
|
||||||
|
double[] rows = new double[components.length]; |
||||||
|
Arrays.fill(rows, p); |
||||||
|
|
||||||
|
return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rows |
||||||
|
, new double[]{f, TableLayout4VanChartHelper.EDIT_AREA_WIDTH}); |
||||||
|
} |
||||||
|
|
||||||
|
protected Component[][] getSouthComps() { |
||||||
|
selectionZoomGroup = new UIButtonGroup<Boolean>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Open") |
||||||
|
, Toolkit.i18nText("Fine-Design_Chart_Close")}, new Boolean[]{true, false}); |
||||||
|
|
||||||
|
return new Component[][]{ |
||||||
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Selection_Zoom")), selectionZoomGroup} |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
protected void initCustomModePane(double[] columnSize, double p) { |
||||||
|
initialDisplayTypeComboBox = new UIComboBox(new ZoomInitialDisplayType[]{ |
||||||
|
ZoomInitialDisplayType.TOP_CATEGORY, |
||||||
|
ZoomInitialDisplayType.LEFT_RIGHT_BOUNDARY}); |
||||||
|
|
||||||
|
Component[][] components = new Component[][]{ |
||||||
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_InitialDisplay")), initialDisplayTypeComboBox} |
||||||
|
}; |
||||||
|
JPanel northPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p}, columnSize); |
||||||
|
|
||||||
|
|
||||||
|
initInitialDisplayCardPane(columnSize, p); |
||||||
|
|
||||||
|
customModePane = new JPanel(new BorderLayout(0, 6)); |
||||||
|
customModePane.add(northPane, BorderLayout.NORTH); |
||||||
|
customModePane.add(initialDisplayCardPane, BorderLayout.CENTER); |
||||||
|
customModePane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); |
||||||
|
} |
||||||
|
|
||||||
|
private void initInitialDisplayCardPane(double[] columnSize, double p) { |
||||||
|
topCategorySpinner = new UISpinner(1, Integer.MAX_VALUE, 1); |
||||||
|
Component[][] components1 = new Component[][]{ |
||||||
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Category_Number")), topCategorySpinner} |
||||||
|
}; |
||||||
|
final JPanel topPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components1, new double[]{p}, columnSize); |
||||||
|
|
||||||
|
|
||||||
|
leftFormulaPane = new TinyFormulaPane(); |
||||||
|
rightFormulaPane = new TinyFormulaPane(); |
||||||
|
Component[][] components2 = new Component[][]{ |
||||||
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Left_Boundary")), leftFormulaPane}, |
||||||
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Right_Boundary")), rightFormulaPane} |
||||||
|
}; |
||||||
|
final JPanel leftRightPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components2, new double[]{p, p}, columnSize); |
||||||
|
|
||||||
|
initialDisplayCardPane = new JPanel(new CardLayout()) { |
||||||
|
@Override |
||||||
|
public Dimension getPreferredSize() { |
||||||
|
return initialDisplayTypeComboBox.getSelectedIndex() == 0 ? topPane.getPreferredSize() : leftRightPane.getPreferredSize(); |
||||||
|
} |
||||||
|
}; |
||||||
|
initialDisplayCardPane.add(topPane, ZoomInitialDisplayType.TOP_CATEGORY.toString()); |
||||||
|
initialDisplayCardPane.add(leftRightPane, ZoomInitialDisplayType.LEFT_RIGHT_BOUNDARY.toString()); |
||||||
|
initialDisplayTypeComboBox.addActionListener(new ActionListener() { |
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
checkInitialDisplayCardPane(); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
private void checkCustomModePane() { |
||||||
|
customModePane.setVisible(modeTypeButtonGroup.getSelectedItem() == ZoomModeType.CUSTOM); |
||||||
|
} |
||||||
|
|
||||||
|
private void checkInitialDisplayCardPane() { |
||||||
|
CardLayout cardLayout = (CardLayout) initialDisplayCardPane.getLayout(); |
||||||
|
if (ComparatorUtils.equals(initialDisplayTypeComboBox.getSelectedItem(), ZoomInitialDisplayType.TOP_CATEGORY)) { |
||||||
|
cardLayout.show(initialDisplayCardPane, ZoomInitialDisplayType.TOP_CATEGORY.toString()); |
||||||
|
} else { |
||||||
|
cardLayout.show(initialDisplayCardPane, ZoomInitialDisplayType.LEFT_RIGHT_BOUNDARY.toString()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(ZoomAttribute ob) { |
||||||
|
modeTypeButtonGroup.setSelectedItem(ob.getModeType()); |
||||||
|
|
||||||
|
initialDisplayTypeComboBox.setSelectedItem(ob.getInitialDisplayType()); |
||||||
|
|
||||||
|
topCategorySpinner.setValue(ob.getTopCategory()); |
||||||
|
|
||||||
|
if (ob.getLeft() != null) { |
||||||
|
leftFormulaPane.populateBean(ob.getLeft().getContent()); |
||||||
|
} |
||||||
|
if (ob.getRight() != null) { |
||||||
|
rightFormulaPane.populateBean(ob.getRight().getContent()); |
||||||
|
} |
||||||
|
|
||||||
|
selectionZoomGroup.setSelectedItem(ob.isSelectionZoom()); |
||||||
|
|
||||||
|
checkInitialDisplayCardPane(); |
||||||
|
checkCustomModePane(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ZoomAttribute updateBean() { |
||||||
|
ZoomAttribute zoomAttribute = new ZoomAttribute(); |
||||||
|
|
||||||
|
zoomAttribute.setModeType(modeTypeButtonGroup.getSelectedItem()); |
||||||
|
|
||||||
|
zoomAttribute.setInitialDisplayType((ZoomInitialDisplayType) initialDisplayTypeComboBox.getSelectedItem()); |
||||||
|
|
||||||
|
zoomAttribute.setTopCategory((int) topCategorySpinner.getValue()); |
||||||
|
|
||||||
|
zoomAttribute.setLeft(new StringFormula(leftFormulaPane.updateBean())); |
||||||
|
zoomAttribute.setRight(new StringFormula(rightFormulaPane.updateBean())); |
||||||
|
|
||||||
|
zoomAttribute.setSelectionZoom(selectionZoomGroup.getSelectedItem()); |
||||||
|
|
||||||
|
return zoomAttribute; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,17 @@ |
|||||||
|
package com.fr.van.chart.designer.other.zoom; |
||||||
|
|
||||||
|
import javax.swing.JPanel; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by shine on 2019/08/28. |
||||||
|
*/ |
||||||
|
public class ZoomPaneWithOutMode extends ZoomPane { |
||||||
|
@Override |
||||||
|
protected JPanel createNorthPane(double f, double p) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void initCustomModePane(double[] columnSize, double p) { |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,85 @@ |
|||||||
|
package com.fr.van.chart.designer.style.component; |
||||||
|
|
||||||
|
import com.fr.chartx.attr.LimitAttribute; |
||||||
|
import com.fr.design.beans.BasicBeanPane; |
||||||
|
import com.fr.design.gui.ibutton.UIButtonGroup; |
||||||
|
import com.fr.design.gui.ispinner.UISpinner; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||||
|
|
||||||
|
import javax.swing.BorderFactory; |
||||||
|
import javax.swing.JPanel; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by shine on 2019/08/28. |
||||||
|
*/ |
||||||
|
public class LimitPane extends BasicBeanPane<LimitAttribute> { |
||||||
|
|
||||||
|
private UIButtonGroup<Boolean> autoCustomTypeGroup; |
||||||
|
private UISpinner maxProportion; |
||||||
|
private JPanel maxProportionPane; |
||||||
|
|
||||||
|
public LimitPane() { |
||||||
|
this(true); |
||||||
|
} |
||||||
|
|
||||||
|
public LimitPane(boolean hasTitle) { |
||||||
|
initComponent(hasTitle); |
||||||
|
} |
||||||
|
|
||||||
|
private void initComponent(boolean hasTitle) { |
||||||
|
maxProportion = new UISpinner(0, 100, 1, 30); |
||||||
|
autoCustomTypeGroup = new UIButtonGroup<Boolean>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Mode_Auto") |
||||||
|
, Toolkit.i18nText("Fine-Design_Chart_Mode_Custom")}, new Boolean[]{true, false}); |
||||||
|
|
||||||
|
JPanel limitSizePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Area_Size"), autoCustomTypeGroup); |
||||||
|
maxProportionPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Max_Proportion"), maxProportion, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); |
||||||
|
maxProportionPane.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 0)); |
||||||
|
JPanel panel = new JPanel(new BorderLayout()); |
||||||
|
panel.add(limitSizePane, BorderLayout.NORTH); |
||||||
|
panel.add(maxProportionPane, BorderLayout.CENTER); |
||||||
|
|
||||||
|
autoCustomTypeGroup.addActionListener(new ActionListener() { |
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
checkMaxProPortionUse(); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
this.setLayout(new BorderLayout()); |
||||||
|
if (hasTitle) { |
||||||
|
JPanel contentPane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), panel); |
||||||
|
this.add(contentPane); |
||||||
|
} else { |
||||||
|
this.add(panel); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
//检查最大显示占比是否可用
|
||||||
|
public void checkMaxProPortionUse() { |
||||||
|
maxProportion.setVisible(!autoCustomTypeGroup.getSelectedItem() && autoCustomTypeGroup.isEnabled()); |
||||||
|
maxProportionPane.setVisible(!autoCustomTypeGroup.getSelectedItem() && autoCustomTypeGroup.isEnabled()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(LimitAttribute ob) { |
||||||
|
autoCustomTypeGroup.setSelectedItem(ob.isAuto()); |
||||||
|
maxProportion.setValue(ob.getMaxSize()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public LimitAttribute updateBean() { |
||||||
|
LimitAttribute attribute = new LimitAttribute(); |
||||||
|
attribute.setAuto(autoCustomTypeGroup.getSelectedItem()); |
||||||
|
attribute.setMaxSize(maxProportion.getValue()); |
||||||
|
return attribute; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue