use of com.cubrid.common.ui.spi.model.BrokerConfig in project cubrid-manager by CUBRID.
the class BrokerConfigEditorPart method createToolBarComp.
/**
* Create the toolbar composition.
*
* @param parent
*/
public void createToolBarComp(Composite parent) {
final Composite comp = new Composite(parent, SWT.NONE);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
comp.setLayoutData(gridData);
final GridLayout layout = new GridLayout(1, false);
layout.marginHeight = -1;
comp.setLayout(layout);
final ToolBar toolbar = new ToolBar(comp, SWT.LEFT_TO_RIGHT | SWT.FLAT);
toolbar.setLayoutData(createGridData(HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
// Show/hide of the history pane
saveConfItem = new ToolItem(toolbar, SWT.PUSH);
saveConfItem.setImage(getImage("icons/queryeditor/file_save.png"));
saveConfItem.setToolTipText(Messages.cubridBrokerConfEditorSaveItemLabel);
saveConfItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
// check whether contains duplicate property name
String errMsg = editorComp.validate();
if (isNotBlank(errMsg)) {
openErrorBox(errMsg);
return;
}
if (!openConfirmBox(Messages.cubridBrokerConfEditorSaveConfirm)) {
return;
}
saveData();
}
});
// Show/hide of the history pane
saveAsConfItem = new ToolItem(toolbar, SWT.PUSH);
saveAsConfItem.setImage(getImage("icons/queryeditor/file_saveas.png"));
saveAsConfItem.setToolTipText(Messages.cubridBrokerConfEditorSaveAsItemLabel);
saveAsConfItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
// Check whether contains duplicate property or broker name
String errMsg = editorComp.validate();
if (isNotBlank(errMsg)) {
openErrorBox(errMsg);
return;
}
if (!openConfirmBox(Messages.cubridBrokerConfEditorSaveAsConfirm)) {
return;
}
final FileDialog dialog = new FileDialog(getSite().getShell(), SWT.OPEN | SWT.MULTI);
dialog.setFilterPath(PersistUtils.getPreferenceValue(PLUGIN_ID, BrokerConfOpenFileDialog.CUBRIDBROKERCONFPATH));
dialog.setText(Messages.cubridBrokerConfEditorSaveAsDialogTitle);
dialog.setFilterExtensions(new String[] { "*.conf" });
dialog.setOverwrite(false);
String path = dialog.open();
File saveAsFile = null;
if (path == null) {
return;
}
if (!path.endsWith(".conf")) {
path += ".conf";
}
saveAsFile = new File(path);
BrokerConfig brokerConf = editorComp.getBrokerConfig();
String contents = persistUtil.readBrokerConfig(brokerConf);
try {
persistUtil.writeBrokerConfig(saveAsFile, charset, contents);
openInformationBox(Messages.titleSuccess, Messages.cubridBrokerConfEditorSaveSucessMsg);
setDirty(false);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
openErrorBox(e.getMessage());
}
}
});
new ToolItem(toolbar, SWT.SEPARATOR);
addPropItem = new ToolItem(toolbar, SWT.PUSH);
addPropItem.setImage(getImage("icons/queryeditor/table_record_insert.png"));
addPropItem.setToolTipText(Messages.cubridBrokerConfEditorAddPropItemLabel);
addPropItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
editorComp.addPropData();
}
});
deletePropItem = new ToolItem(toolbar, SWT.PUSH);
deletePropItem.setImage(getImage("icons/queryeditor/table_record_delete.png"));
deletePropItem.setToolTipText(Messages.cubridBrokerConfEditorDeletePropItemLabel);
deletePropItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
editorComp.deletePropData();
}
});
}
use of com.cubrid.common.ui.spi.model.BrokerConfig in project cubrid-manager by CUBRID.
the class UnifyHostConfigEditor method createBrokerConfTableData.
/**
* create table data by CubridBrokerConf model
*/
public void createBrokerConfTableData() {
//remove column
int oldCount = brokerConfTabTableViewer.getTable().getColumnCount();
for (int i = 0; i < oldCount; i++) {
brokerConfTabTableViewer.getTable().getColumn(0).dispose();
}
//create column
TableViewerColumn column = new TableViewerColumn(brokerConfTabTableViewer, SWT.LEFT);
column.getColumn().setWidth(150);
column.getColumn().setText(Messages.unifyHostConfTableColumnPropName);
column.setEditingSupport(new PropValueEditingSupport(brokerConfTabTableViewer, 0));
int columnIndex = 0;
for (Entry<String, BrokerConfig> entry : cubridBrokerConfigDataMap.entrySet()) {
BrokerConfig cubridBrokerConfig = entry.getValue();
for (int i = 0; i < cubridBrokerConfig.getPropertyList().size(); i++) {
TableViewerColumn propColumn = new TableViewerColumn(brokerConfTabTableViewer, SWT.LEFT);
propColumn.getColumn().setWidth(160);
propColumn.getColumn().setText(Messages.unifyHostBrokerConfTableTitle + columnIndex);
propColumn.setEditingSupport(new PropValueEditingSupport(brokerConfTabTableViewer, columnIndex + 1));
propColumn.getColumn().addSelectionListener(new SelectionAdapter() {
@SuppressWarnings("all")
public void widgetSelected(SelectionEvent event) {
}
});
//if broker name is [broker] can't edit and don't display
// CubridBrokerProperty brokerProperty = cubridBrokerConfig.getPropertyList().get(i);
// if (brokerProperty.getCubridBrokerPropKey().equals("[broker]")) {
// propColumn.getColumn().setWidth(0);
// }
columnIndex++;
}
}
brokerConfTabTableViewer.setLabelProvider(new UnifyHostCubridBrokerTableLabelProvider());
brokerConfTabTableViewer.setInput(cubridBrokerConfListData);
cubridBrokerConfListData.clear();
cubridBrokerConfListData.addAll(unifyHostConfigUtil.parseCubridBrokerConfigToCommonTableValue(cubridBrokerConfigDataMap));
brokerConfTabTableViewer.refresh();
}
use of com.cubrid.common.ui.spi.model.BrokerConfig in project cubrid-manager by CUBRID.
the class UnifyHostConfigEditor method addBrokerConfColumn.
/**
* addBrokerConfColumn
*/
public void addBrokerConfColumn() {
editorInput.setBrokerConfPropertyCount(brokerConfTabTableViewer.getTable().getColumnCount());
LinkedHashMap<String, BrokerConfig> brokerConfMap = unifyHostConfigUtil.parseCommonTableValueToCubridBrokerConfig(cubridBrokerConfListData, editorInput.getBrokerConfPropertyCount());
Point pt = cubridBrokerTableClickPoint;
int selectIndex = brokerConfTabTableViewer.getTable().getSelectionIndex();
if (selectIndex < 0) {
return;
}
final TableItem item = brokerConfTabTableViewer.getTable().getItem(selectIndex);
if (item == null) {
return;
}
for (int i = 0; i < brokerConfTabTableViewer.getTable().getColumnCount(); i++) {
Rectangle rect = item.getBounds(i);
if (rect.contains(pt)) {
cubridBrokerConfListData.clear();
cubridBrokerConfListData.addAll(unifyHostConfigUtil.parseCubridBrokerConfigToCommonTableValue(cubridBrokerConfigDataMap));
String serverName = cubridBrokerConfListData.get(0).get(i + "");
if (!CommonUITool.openConfirmBox(Messages.bind(Messages.unifyHostConfigEditorAddColumnConfirmMsg, "broker", serverName))) {
return;
}
BrokerConfig cubridBrokerConfig = brokerConfMap.get(serverName);
//new property then set parameter
CubridBrokerProperty property = new CubridBrokerProperty();
property.setCubridBrokerPropKey("[%broker" + (cubridBrokerConfig.getPropertyList().size() + 1) + "]");
property.setCubridBroker(true);
property.setCubridBrokerPropAnnotation(StringUtil.NEWLINE);
cubridBrokerConfig.addCubridBrokerProperty(property);
cubridBrokerConfigDataMap.clear();
cubridBrokerConfigDataMap.putAll(brokerConfMap);
createBrokerConfTableData();
setDirty(true);
return;
}
}
}
use of com.cubrid.common.ui.spi.model.BrokerConfig in project cubrid-manager by CUBRID.
the class UnifyHostConfigEditor method loadData.
/**
* load edit data
*/
public void loadData() {
if (editorInput.getTaskCountValue() == 0) {
return;
}
try {
ProgressMonitorDialog progress = new ProgressMonitorDialog(getSite().getShell());
progress.setCancelable(false);
progress.run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
monitor.beginTask(Messages.unifyHostConfigEditorLoadingDataMsg, editorInput.getTaskCountValue());
unifyHostConfigUtil = new UnifyHostConfigUtil();
for (CubridServer cubridServer : editorInput.getCubridServers()) {
if (editorInput.isEditCubridConf()) {
monitor.subTask(Messages.bind(Messages.unifyHostConfigEditorLoadingDataMsg2, "cubrid.conf", cubridServer.getName()));
GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(cubridServer.getServerInfo());
getCubridConfParameterTask.execute();
if (getCubridConfParameterTask.isSuccess()) {
List<String> contentsList = getCubridConfParameterTask.getConfContents();
StringBuilder contentBuilder = new StringBuilder();
for (String content : contentsList) {
contentBuilder.append(content).append(StringUtil.NEWLINE);
}
CubridConfConfig cubridConfConfig = unifyHostConfigUtil.parseStringLineToCubridConfConfig(contentBuilder.toString());
cubridConfConfigDataMap.put(cubridServer.getName(), cubridConfConfig);
monitor.worked(1);
}
}
if (editorInput.isEditBrokerConf()) {
monitor.subTask(Messages.bind(Messages.unifyHostConfigEditorLoadingDataMsg2, "broker", cubridServer.getName()));
GetBrokerConfParameterTask getBrokerConfParameterTask = new GetBrokerConfParameterTask(cubridServer.getServerInfo());
getBrokerConfParameterTask.execute();
if (getBrokerConfParameterTask.isSuccess()) {
List<String> contentsList = getBrokerConfParameterTask.getConfContents();
StringBuilder contentBuilder = new StringBuilder();
for (String content : contentsList) {
contentBuilder.append(content).append(StringUtil.NEWLINE);
}
BrokerConfig cubridBrokerConfig = cubridBrokerConfUtil.parseStringLineToBrokerConfig(contentBuilder.toString());
cubridBrokerConfigDataMap.put(cubridServer.getName(), cubridBrokerConfig);
monitor.worked(1);
}
}
if (editorInput.isEditCMConf()) {
monitor.subTask(Messages.bind(Messages.unifyHostConfigEditorLoadingDataMsg2, "cm.conf", cubridServer.getName()));
GetCMConfParameterTask getCMConfParameterTask = new GetCMConfParameterTask(cubridServer.getServerInfo());
getCMConfParameterTask.execute();
if (getCMConfParameterTask.isSuccess()) {
List<String> contentsList = getCMConfParameterTask.getConfContents();
StringBuilder contentBuilder = new StringBuilder();
for (String content : contentsList) {
contentBuilder.append(content).append(StringUtil.NEWLINE);
}
CubridCMConfConfig cubridCMConfConfig = unifyHostConfigUtil.parseStringLineToCubridCMConfConfig(contentBuilder.toString());
cubridConfCMConfigDataMap.put(cubridServer.getName(), cubridCMConfConfig);
// System.out.println(contentBuilder.toString());
}
monitor.worked(1);
}
if (editorInput.isEditHAConf()) {
monitor.subTask(Messages.bind(Messages.unifyHostConfigEditorLoadingDataMsg2, "cubrid_ha.conf", cubridServer.getName()));
monitor.worked(1);
}
if (editorInput.isEditACLConf()) {
monitor.subTask(Messages.bind(Messages.unifyHostConfigEditorLoadingDataMsg2, "acl", cubridServer.getName()));
monitor.worked(1);
}
}
}
});
} catch (Exception e) {
LOGGER.error("", e);
}
}
use of com.cubrid.common.ui.spi.model.BrokerConfig in project cubrid-manager by CUBRID.
the class EditCMCubridBrokerConfPart method doSave.
public void doSave(IProgressMonitor monitor) {
BrokerConfig cubridBrokerConfig = editorComp.getBrokerConfig();
String errMsg = editorComp.validate();
if (errMsg != null) {
CommonUITool.openErrorBox(errMsg);
return;
}
String contents = brokerConfPersistUtil.readBrokerConfig(cubridBrokerConfig);
ConfigParaHelp.performImportBrokerConf(editorInput.getServerInfo(), contents);
setDirty(false);
}
Aggregations