for (int i = 0; i < table.getRowCount(); i++) {
Boolean isSelect = (Boolean) table.getValueAt(i, 0);
String appId = (String) table.getValueAt(i, 1);
if (isSelect == true) {
try {
Application application = ConfigMamager.getReader().getAppById(appId);
if (Application.RUNNING.equals(application.getState())) {
continue;
}
application.setState(Application.RUNNING);
AppManagerToolkit.getAppManager().startApp(application);
} catch (Exception ex) {
sb.append(ex.getMessage());
continue;
}
}
}
table.repaintTable();
if (sb.length() > 0) {
BaseFrame.alert(sb.toString());
}
} catch (Exception ex) {
BaseFrame.alert(ex.getMessage());
}
}
});
appStopButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < table.getRowCount(); i++) {
Boolean isSelect = (Boolean) table.getValueAt(i, 0);
if (isSelect == true) {
try {
String appId = (String) table.getValueAt(i, 1);
Application application = ConfigMamager.getReader().getAppById(appId);
if (Application.STOPED.equals(application.getState())) {
continue;
}
application.setState(Application.STOPED);
AppManagerToolkit.getAppManager().stopApp(application);
} catch (Exception ex) {
sb.append(ex.getMessage());
continue;
}
}
}
table.repaintTable();
if (sb.length() > 0) {
BaseFrame.alert(sb.toString());
}
} catch (Exception ex) {
BaseFrame.alert(ex.getMessage());
}
}
});
removeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
List<String> appIds = new ArrayList<String>();
for (int i = 0; i < table.getRowCount(); i++) {
Boolean isSelect = (Boolean) table.getValueAt(i, 0);
String appId = (String) table.getValueAt(i, 1);
if (isSelect == true) {
String status;
status = ConfigMamager.getReader().getAppById(appId).getState();
if (Application.RUNNING.equals(status)) {
BaseFrame.alert("ж��֮ǰ����ֹͣӦ��!");
return;
}
appIds.add(appId);
}
}
if (appIds.size() == 0) {
BaseFrame.alert("��ѡ����Ҫж�ص�Ӧ�ã�");
return;
}
ConfigMamager.getReader().removeApp(appIds);
table.repaintTable();
} catch (Exception e1) {
BaseFrame.alert(e1.getMessage());
}
}
});
restartButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < table.getRowCount(); i++) {
Boolean isSelect = (Boolean) table.getValueAt(i, 0);
if (isSelect == true) {
try {
String appId = (String) table.getValueAt(i, 1);
Application application = ConfigMamager.getReader().getAppById(appId);
application.setState(Application.STOPED);
AppManagerToolkit.getAppManager().stopApp(application);
application.setState(Application.RUNNING);
AppManagerToolkit.getAppManager().startApp(application);
} catch (Exception ex) {
sb.append(ex.getMessage());
continue;
}
}
}
table.repaintTable();
if (sb.length() > 0) {
BaseFrame.alert(sb.toString());
}
} catch (Exception ex) {
BaseFrame.alert(ex.getMessage());
}
}
});
refreshButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
List<Application> appList = ConfigMamager.getReader().getAppList();
Application modifyApp = new Application();
for (Iterator<Application> it = appList.iterator(); it.hasNext();) {
Application app = (Application) it.next();
String pid = ProcessTookit.getIProcessManager().getPIDByAppId(app.getId());
if (pid == null || ProcessTookit.getIProcessManager().getMemByPID(pid) == null) {
app.setState(Application.STOPED);
modifyApp.addBrother(app);
}
}
if (modifyApp.hasBrother()) {// ��������
AppManagerToolkit.getAppManager().stopApp(modifyApp.getBrother());