use of com.cubrid.common.ui.spi.model.CubridServer in project cubrid-manager by CUBRID.
the class SettingHostPage method createControl.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new FormLayout());
setControl(container);
setDescription(Messages.descSettingHostPage);
setPageComplete(false);
Composite leftComposite = new Composite(container, SWT.NONE);
leftComposite.setLayout(new GridLayout(2, false));
FormData leftData = new FormData();
leftData.top = new FormAttachment(0, 5);
leftData.bottom = new FormAttachment(100, 0);
leftData.left = new FormAttachment(0, 5);
leftData.right = new FormAttachment(50, -5);
leftComposite.setLayoutData(leftData);
Label separator = new Label(container, SWT.SEPARATOR);
FormData separatorData = new FormData();
separatorData.top = new FormAttachment(0, 5);
separatorData.bottom = new FormAttachment(100, -5);
separatorData.left = new FormAttachment(50, -5);
separatorData.right = new FormAttachment(50, 5);
separator.setLayoutData(separatorData);
Composite rightComposite = new Composite(container, SWT.NONE);
rightComposite.setLayout(new GridLayout(3, false));
FormData rightData = new FormData();
rightData.top = new FormAttachment(0, 5);
rightData.bottom = new FormAttachment(100, 0);
rightData.left = new FormAttachment(50, 5);
rightData.right = new FormAttachment(100, -5);
rightComposite.setLayoutData(rightData);
/*Create left widget*/
Label hostALabel = new Label(leftComposite, SWT.None);
hostALabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
hostALabel.setText(Messages.lblMaster);
masterHostText = new Text(leftComposite, SWT.BORDER);
masterHostText.setEnabled(false);
masterHostText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
Label masterNameLabel = new Label(leftComposite, SWT.None);
masterNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
masterNameLabel.setText(Messages.lblMasterHost);
masterHostName = new Text(leftComposite, SWT.BORDER);
masterHostName.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
masterHostName.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
validate();
}
});
masterDBList = new org.eclipse.swt.widgets.List(leftComposite, SWT.BORDER);
masterDBList.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 2, 1, -1, -1));
masterDBList.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
validate();
}
});
/*Create right widget*/
Label hostBLabel = new Label(rightComposite, SWT.None);
hostBLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
hostBLabel.setText(Messages.lblSlave);
slaveHostCombo = new Combo(rightComposite, SWT.READ_ONLY);
slaveHostCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
slaveHostCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
selectedSlaveServer = null;
String serverName = slaveHostCombo.getText();
List<CubridServer> serverList = CMHostNodePersistManager.getInstance().getAllServers();
for (CubridServer server : serverList) {
if (serverName.equals(server.getName())) {
selectedSlaveServer = server;
break;
}
}
initSlaveDBList(selectedSlaveServer);
validate();
}
});
Label slaveNameLabel = new Label(rightComposite, SWT.None);
slaveNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
slaveNameLabel.setText(Messages.lblSlaveHost);
slaveHostName = new Text(rightComposite, SWT.BORDER);
slaveHostName.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
slaveHostName.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
validate();
}
});
slaveDBList = new org.eclipse.swt.widgets.List(rightComposite, SWT.BORDER);
slaveDBList.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, -1));
slaveDBList.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
validate();
}
});
init();
}
use of com.cubrid.common.ui.spi.model.CubridServer in project cubrid-manager by CUBRID.
the class ImportExportConnectionDialog method parseFile.
protected void parseFile(String fileName) {
int repeatCount = 0;
List<CubridServer> newServerList = new ArrayList<CubridServer>();
File file = new File(fileName);
if (!file.exists()) {
return;
}
FileInputStream fis = null;
try {
fis = new FileInputStream(file);
IXMLMemento xmlContent = XMLMemento.loadMemento(fis);
List<CubridServer> list = new ArrayList<CubridServer>();
CMHostNodePersistManager.getInstance().loadServers(xmlContent, false, EMPTY_STR, list);
for (CubridServer server : list) {
if (!isContainSameHost(server)) {
newServerList.add(server);
} else {
repeatCount++;
}
}
} catch (Exception e) {
LOGGER.error("", e);
} finally {
FileUtil.close(fis);
}
if (repeatCount > 0) {
setMessage(Messages.bind(Messages.msgInfoSame, repeatCount), IMessageProvider.WARNING);
} else {
setMessage(null);
}
hostListView.setInput(newServerList);
hostListView.refresh();
}
use of com.cubrid.common.ui.spi.model.CubridServer in project cubrid-manager by CUBRID.
the class StartServiceAction method isSupported.
/**
*
* Return whether this action support this object,if not support,this action
* will be disabled
*
* @param obj the Object
* @return <code>true</code> if support this object;<code>false</code>
* otherwise
*/
public boolean isSupported(Object obj) {
if (obj instanceof ICubridNode) {
ICubridNode node = (ICubridNode) obj;
CubridServer server = node.getServer();
if (server == null) {
return false;
}
ServerInfo serverInfo = server.getServerInfo();
ServerType serverType = serverInfo == null ? null : serverInfo.getServerType();
if (serverType == null || serverType == ServerType.BROKER) {
return false;
}
if (server != null && server.isConnected() && serverInfo != null && serverInfo.getLoginedUserInfo() != null && serverInfo.getLoginedUserInfo().isAdmin()) {
return true;
}
}
return false;
}
use of com.cubrid.common.ui.spi.model.CubridServer in project cubrid-manager by CUBRID.
the class StopServiceAction method doRun.
/**
* Perform do run
*
* @param servers
*/
public void doRun(CubridServer[] servers) {
CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
final TreeViewer viewer = view.getViewer();
if (servers.length > 0) {
CubridServer server = servers[0];
if (isSupported(server)) {
final JobFamily jobFamily = new JobFamily();
final String serverName = server.getName();
String dbName = JobFamily.ALL_DB;
jobFamily.setServerName(serverName);
jobFamily.setDbName(dbName);
Job[] jobs = Job.getJobManager().find(jobFamily);
if (jobs.length > 0) {
CommonUITool.openWarningBox(Messages.bind(Messages.msgStopServiceWithJob, serverName));
return;
}
TaskExecutor taskExcutor = new StopServiceExecutor(server, getShell(), viewer);
ServerInfo serverInfo = server.getServerInfo();
GetCubridConfParameterTask task = new GetCubridConfParameterTask(serverInfo);
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).exec();
}
}
// for(CubridServer server : servers) {
// final JobFamily jobFamily = new JobFamily();
// final String serverName = server.getName();
// String dbName = JobFamily.ALL_DB;
// jobFamily.setServerName(serverName);
// jobFamily.setDbName(dbName);
// Job[] jobs = Job.getJobManager().find(jobFamily);
// if (jobs.length > 0) {
// CommonUITool.openWarningBox(Messages.bind(
// Messages.msgStopServiceWithJob, serverName));
// return;
// }
//
// TaskExecutor taskExcutor = new StopServiceExecutor(server, getShell(),
// viewer);
// ServerInfo serverInfo = server.getServerInfo();
// GetCubridConfParameterTask task = new GetCubridConfParameterTask(
// serverInfo);
// taskExcutor.addTask(task);
// new ExecTaskWithProgress(taskExcutor).exec();
// }
}
use of com.cubrid.common.ui.spi.model.CubridServer in project cubrid-manager by CUBRID.
the class ViewServerVersionAction method isSupported.
/**
*
* Return whether this action support this object,if not support,this action
* will be disabled
*
* @param obj the Object
* @return <code>true</code> if support this obj;<code>false</code>
* otherwise
*/
public boolean isSupported(Object obj) {
if (obj instanceof ICubridNode) {
ICubridNode node = (ICubridNode) obj;
CubridServer server = node.getServer();
return server != null && server.isConnected();
}
return false;
}
Aggregations