Search in sources :

Example 1 with CubridConfConfig

use of com.cubrid.cubridmanager.ui.host.model.CubridConfConfig in project cubrid-manager by CUBRID.

the class UnifyHostConfigEditor method delCubridConfColumn.

/**
	 * delCubridConfColumn
	 */
public void delCubridConfColumn() {
    editorInput.setCubridConfPropertyCount(cubridConfTabTableViewer.getTable().getColumnCount());
    LinkedHashMap<String, CubridConfConfig> cubridConfMap = unifyHostConfigUtil.parseCommonTableValueToCubridConfConfig(cubridConfConfigListData, editorInput.getCubridConfPropertyCount());
    Point pt = cubridConfTableClickPoint;
    int selectIndex = cubridConfTabTableViewer.getTable().getSelectionIndex();
    if (selectIndex < 0) {
        return;
    }
    final TableItem item = cubridConfTabTableViewer.getTable().getItem(selectIndex);
    if (item == null) {
        return;
    }
    for (int i = 0; i < cubridConfTabTableViewer.getTable().getColumnCount(); i++) {
        Rectangle rect = item.getBounds(i);
        if (rect.contains(pt)) {
            cubridConfConfigListData.clear();
            cubridConfConfigListData.addAll(unifyHostConfigUtil.parseCubridConfConfigToCommonTableValue(cubridConfConfigDataMap));
            String serverName = cubridConfConfigListData.get(0).get(i + "");
            String sectionName = cubridConfConfigListData.get(1).get(i + "");
            if (!CommonUITool.openConfirmBox(Messages.bind(Messages.unifyHostConfigEditorDelColumnConfirmMsg, sectionName, serverName))) {
                return;
            }
            CubridConfConfig cubridConfConfig = cubridConfMap.get(serverName);
            unifyHostConfigUtil.deleteCubridConfPropertyBySectionName(cubridConfConfig, sectionName);
            cubridConfConfigDataMap.clear();
            cubridConfConfigDataMap.putAll(cubridConfMap);
            createCubridConfTableData();
            setDirty(true);
            return;
        }
    }
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) CubridConfConfig(com.cubrid.cubridmanager.ui.host.model.CubridConfConfig) Point(org.eclipse.swt.graphics.Point)

Example 2 with CubridConfConfig

use of com.cubrid.cubridmanager.ui.host.model.CubridConfConfig 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);
    }
}
Also used : BrokerConfig(com.cubrid.common.ui.spi.model.BrokerConfig) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) GetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) UnifyHostConfigUtil(com.cubrid.cubridmanager.ui.spi.util.UnifyHostConfigUtil) InvocationTargetException(java.lang.reflect.InvocationTargetException) CubridConfConfig(com.cubrid.cubridmanager.ui.host.model.CubridConfConfig) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) GetCMConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask) List(java.util.List) ArrayList(java.util.ArrayList) GetBrokerConfParameterTask(com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask) CubridCMConfConfig(com.cubrid.cubridmanager.ui.host.model.CubridCMConfConfig)

Example 3 with CubridConfConfig

use of com.cubrid.cubridmanager.ui.host.model.CubridConfConfig in project cubrid-manager by CUBRID.

the class UnifyHostConfigEditor method addCubridConfColumn.

/**
	 * addCubridConfColumn
	 */
public void addCubridConfColumn() {
    editorInput.setCubridConfPropertyCount(cubridConfTabTableViewer.getTable().getColumnCount());
    LinkedHashMap<String, CubridConfConfig> cubridConfMap = unifyHostConfigUtil.parseCommonTableValueToCubridConfConfig(cubridConfConfigListData, editorInput.getCubridConfPropertyCount());
    Point pt = cubridConfTableClickPoint;
    int selectIndex = cubridConfTabTableViewer.getTable().getSelectionIndex();
    if (selectIndex < 0) {
        return;
    }
    final TableItem item = cubridConfTabTableViewer.getTable().getItem(selectIndex);
    if (item == null) {
        return;
    }
    for (int i = 0; i < cubridConfTabTableViewer.getTable().getColumnCount(); i++) {
        Rectangle rect = item.getBounds(i);
        if (rect.contains(pt)) {
            cubridConfConfigListData.clear();
            cubridConfConfigListData.addAll(unifyHostConfigUtil.parseCubridConfConfigToCommonTableValue(cubridConfConfigDataMap));
            String serverName = cubridConfConfigListData.get(0).get(i + "");
            if (!CommonUITool.openConfirmBox(Messages.bind(Messages.unifyHostConfigEditorAddColumnConfirmMsg, "section", serverName))) {
                return;
            }
            CubridConfConfig cubridConfConfig = cubridConfMap.get(serverName);
            //new property then set parameter
            CubridConfProperty property = new CubridConfProperty();
            property.setCubridConfPropKey("[%section" + (cubridConfConfig.getPropertyList().size() + 1) + "]");
            property.setCubridConf(true);
            property.setCubridConfPropAnnotation(StringUtil.NEWLINE);
            cubridConfConfig.addCubridConfProperty(property);
            cubridConfConfigDataMap.clear();
            cubridConfConfigDataMap.putAll(cubridConfMap);
            createCubridConfTableData();
            setDirty(true);
            return;
        }
    }
}
Also used : CubridConfProperty(com.cubrid.cubridmanager.ui.host.model.CubridConfProperty) TableItem(org.eclipse.swt.widgets.TableItem) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) CubridConfConfig(com.cubrid.cubridmanager.ui.host.model.CubridConfConfig) Point(org.eclipse.swt.graphics.Point)

Example 4 with CubridConfConfig

use of com.cubrid.cubridmanager.ui.host.model.CubridConfConfig in project cubrid-manager by CUBRID.

the class UnifyHostConfigEditor method createCubridConfTableData.

/**
	 * create table data by cubridConfConfig model
	 */
public void createCubridConfTableData() {
    //remove column
    int oldCount = cubridConfTabTableViewer.getTable().getColumnCount();
    for (int i = 0; i < oldCount; i++) {
        cubridConfTabTableViewer.getTable().getColumn(0).dispose();
    }
    //create column
    TableViewerColumn column = new TableViewerColumn(cubridConfTabTableViewer, SWT.LEFT);
    column.getColumn().setWidth(150);
    column.getColumn().setText(Messages.unifyHostConfTableColumnPropName);
    column.setEditingSupport(new PropValueEditingSupport(cubridConfTabTableViewer, 0));
    int columnIndex = 0;
    for (Entry<String, CubridConfConfig> entry : cubridConfConfigDataMap.entrySet()) {
        CubridConfConfig cubridConfConfig = entry.getValue();
        for (int i = 0; i < cubridConfConfig.getPropertyList().size(); i++) {
            TableViewerColumn propColumn = new TableViewerColumn(cubridConfTabTableViewer, SWT.LEFT);
            propColumn.getColumn().setWidth(160);
            propColumn.getColumn().setText(Messages.unifyHostCubridConfTableTitle + columnIndex);
            propColumn.setEditingSupport(new PropValueEditingSupport(cubridConfTabTableViewer, columnIndex + 1));
            propColumn.getColumn().addSelectionListener(new SelectionAdapter() {

                @SuppressWarnings("all")
                public void widgetSelected(SelectionEvent event) {
                }
            });
            columnIndex++;
        }
    }
    cubridConfTabTableViewer.setLabelProvider(new UnifyHostCubridConfTableLabelProvider());
    cubridConfTabTableViewer.setInput(cubridConfConfigListData);
    cubridConfConfigListData.clear();
    cubridConfConfigListData.addAll(unifyHostConfigUtil.parseCubridConfConfigToCommonTableValue(cubridConfConfigDataMap));
    cubridConfTabTableViewer.refresh();
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Point(org.eclipse.swt.graphics.Point) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) CubridConfConfig(com.cubrid.cubridmanager.ui.host.model.CubridConfConfig)

Example 5 with CubridConfConfig

use of com.cubrid.cubridmanager.ui.host.model.CubridConfConfig in project cubrid-manager by CUBRID.

the class UnifyHostConfigUtil method parseStringLineToCubridConfConfig.

/**
	 * parseStringLineToCubridConfConfig
	 * @param content
	 * @return
	 * @throws Exception
	 */
public CubridConfConfig parseStringLineToCubridConfConfig(String content) {
    CubridConfConfig config = new CubridConfConfig();
    String cubridConfRegex = "\\[.*";
    Pattern cubridConfPattern = Pattern.compile(cubridConfRegex);
    String annotationRegex = "#(\\s*).+";
    Pattern annotationPattern = Pattern.compile(annotationRegex);
    String propertyRegex = ".+=.+";
    Pattern propertyPattern = Pattern.compile(propertyRegex);
    CubridConfProperty confProp = null;
    StringBuilder annotationBuilder = new StringBuilder();
    String[] contentArray = content.split(StringUtil.NEWLINE);
    for (String lineString : contentArray) {
        Matcher cubridConfMatcher = cubridConfPattern.matcher(lineString);
        Matcher annotationMatcher = annotationPattern.matcher(lineString);
        Matcher propertyMatcher = propertyPattern.matcher(lineString);
        if (cubridConfMatcher.find()) {
            //find broker like [service] [common] [@database]
            confProp = new CubridConfProperty();
            confProp.setCubridConfPropKey(lineString);
            confProp.setCubridConf(true);
            if (annotationBuilder != null) {
                confProp.setCubridConfPropAnnotation(annotationBuilder.toString());
            }
            config.addCubridConfProperty(confProp);
            annotationBuilder = null;
        } else if (annotationMatcher.find() || lineString.equals("")) {
            //find annotation
            if (annotationBuilder == null) {
                annotationBuilder = new StringBuilder();
            }
            annotationBuilder.append(lineString).append(StringUtil.NEWLINE);
        } else if (propertyMatcher.find()) {
            //find key and value
            if (confProp == null) {
                //if there is no cubrid conf,ignore the property
                continue;
            }
            String[] keyValueString = lineString.split("=");
            if (keyValueString.length == 2) {
                String key = keyValueString[0].trim();
                String value = keyValueString[1].trim();
                //new property then set parameter
                CubridConfProperty property = new CubridConfProperty();
                property.setCubridConfPropKey(key);
                property.setCubridConfPropValue(value);
                if (annotationBuilder != null) {
                    property.setCubridConfPropAnnotation(annotationBuilder.toString());
                }
                confProp.addCubridConfProperty(property);
                annotationBuilder = null;
            }
        } else {
            //opthers see it to bottom annotation
            annotationBuilder.append(lineString).append(StringUtil.NEWLINE);
        }
    }
    if (annotationBuilder != null) {
        config.setConfAnnotation(annotationBuilder.toString());
    }
    return config;
}
Also used : CubridConfProperty(com.cubrid.cubridmanager.ui.host.model.CubridConfProperty) Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) CubridConfConfig(com.cubrid.cubridmanager.ui.host.model.CubridConfConfig)

Aggregations

CubridConfConfig (com.cubrid.cubridmanager.ui.host.model.CubridConfConfig)8 CubridConfProperty (com.cubrid.cubridmanager.ui.host.model.CubridConfProperty)4 ArrayList (java.util.ArrayList)3 Point (org.eclipse.swt.graphics.Point)3 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 Rectangle (org.eclipse.swt.graphics.Rectangle)2 TableItem (org.eclipse.swt.widgets.TableItem)2 BrokerConfig (com.cubrid.common.ui.spi.model.BrokerConfig)1 GetBrokerConfParameterTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask)1 GetCMConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask)1 GetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask)1 SetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.SetCubridConfParameterTask)1 CubridCMConfConfig (com.cubrid.cubridmanager.ui.host.model.CubridCMConfConfig)1 UnifyHostConfigUtil (com.cubrid.cubridmanager.ui.spi.util.UnifyHostConfigUtil)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 List (java.util.List)1 Matcher (java.util.regex.Matcher)1