forked from fanruan/design
pengda
5 years ago
14 changed files with 259 additions and 64 deletions
@ -0,0 +1,73 @@
|
||||
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.general.os.OSBasedAction; |
||||
import com.fr.stable.os.OperatingSystem; |
||||
import com.fr.transaction.CallBackAdaptor; |
||||
import com.fr.transaction.Configurations; |
||||
import com.fr.transaction.WorkerFacade; |
||||
import static com.fr.design.actions.server.ConnectionListAction.doWithDatasourceManager; |
||||
|
||||
//数据连接窗口
|
||||
public class DatabaseDialogAction implements OSBasedAction { |
||||
|
||||
@Override |
||||
public void execute() { |
||||
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,26 @@
|
||||
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.general.os.OSBasedAction; |
||||
import com.fr.stable.os.Arch; |
||||
import com.fr.stable.os.OperatingSystem; |
||||
|
||||
//插件管理窗口
|
||||
public class PMDialogAction implements OSBasedAction { |
||||
private static String PLUGIN_MANAGER_ROUTE = "#management/plugin"; |
||||
@Override |
||||
public void execute() { |
||||
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,27 @@
|
||||
package com.fr.design.os.impl; |
||||
|
||||
import com.fr.general.os.SupportOS; |
||||
import com.fr.stable.os.Arch; |
||||
import com.fr.stable.os.OperatingSystem; |
||||
|
||||
public enum SupportOSImpl implements SupportOS { |
||||
//登录
|
||||
USERINFOPANE{ |
||||
public boolean support(){ |
||||
return Arch.getArch() != Arch.ARM; |
||||
} |
||||
}, |
||||
//透明度
|
||||
OPACITY{ |
||||
public boolean support(){ |
||||
return !OperatingSystem.isLinux(); |
||||
} |
||||
}, |
||||
//FineUI选项
|
||||
FINEUI{ |
||||
public boolean support(){ |
||||
return !OperatingSystem.isLinux(); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,22 @@
|
||||
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.general.os.OSBasedAction; |
||||
import com.fr.stable.os.OperatingSystem; |
||||
|
||||
//更新升级窗口
|
||||
public class UpdateDialogAction implements OSBasedAction { |
||||
private static String UPDATE_ROUTE = "#management/backup"; |
||||
@Override |
||||
public void execute() { |
||||
if(!OperatingSystem.isLinux()) { |
||||
UpdateMainDialog dialog = new UpdateMainDialog(DesignerContext.getDesignerFrame()); |
||||
dialog.showDialog(); |
||||
}else{ |
||||
DesignUtils.visitEnvServerByParameters( UPDATE_ROUTE,null,null); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,6 @@
|
||||
package com.fr.design; |
||||
|
||||
public interface OSBasedAction { |
||||
void execute(); |
||||
} |
||||
|
@ -0,0 +1,25 @@
|
||||
package com.fr.design; |
||||
|
||||
import com.fr.invoke.Reflect; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
public class OSSupportCenter { |
||||
|
||||
private static Map<Class,OSBasedAction> osBasedActionMap = new HashMap<Class,OSBasedAction>(); |
||||
public static void buildAction(OSBasedAction action, SupportOS supportOS){ |
||||
if(supportOS.support()){ |
||||
action.execute(); |
||||
} |
||||
} |
||||
|
||||
public static <T extends OSBasedAction> T getAction(Class clazz) { |
||||
OSBasedAction action = osBasedActionMap.get(clazz); |
||||
if(action == null){ |
||||
action = Reflect.on(clazz).create().get(); |
||||
osBasedActionMap.put(clazz,action); |
||||
} |
||||
return (T) action; |
||||
} |
||||
} |
@ -0,0 +1,6 @@
|
||||
package com.fr.design; |
||||
|
||||
public interface SupportOS { |
||||
//判断是否支持
|
||||
boolean support(); |
||||
} |
Loading…
Reference in new issue