forked from fanruan/design
28 changed files with 517 additions and 166 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); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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); |
||||||
} |
} |
||||||
} |
} |
Loading…
Reference in new issue