Search in sources :

Example 1 with ImportConfigDialog

use of com.cubrid.cubridmanager.ui.host.dialog.ImportConfigDialog in project cubrid-manager by CUBRID.

the class ImportCubridConfigAction method run.

/**
	 * Open the import cubrid property dialog
	 */
public void run() {
    final Object[] obj = this.getSelectedObj();
    if (obj == null || obj.length <= 0) {
        setEnabled(false);
        return;
    }
    CubridServer server = (CubridServer) getSelectedObj()[0];
    ImportConfigDialog dialog = new ImportConfigDialog(getShell(), ConfigType.CUBRID);
    if (dialog.open() == Dialog.OK) {
        List<String> contents = dialog.getImportFileContent();
        ConfigParaHelp.performImportCubridConf(server.getServerInfo(), contents);
    }
}
Also used : ImportConfigDialog(com.cubrid.cubridmanager.ui.host.dialog.ImportConfigDialog) CubridServer(com.cubrid.common.ui.spi.model.CubridServer)

Example 2 with ImportConfigDialog

use of com.cubrid.cubridmanager.ui.host.dialog.ImportConfigDialog in project cubrid-manager by CUBRID.

the class ImportCmConfigAction method run.

/**
	 * Open the importcm property dialog
	 */
public void run() {
    final Object[] obj = this.getSelectedObj();
    if (obj == null || obj.length <= 0) {
        setEnabled(false);
        return;
    }
    CubridServer server = (CubridServer) getSelectedObj()[0];
    ImportConfigDialog dialog = new ImportConfigDialog(getShell(), ConfigType.CUBRID_MANAGER);
    if (dialog.open() == Dialog.OK) {
        List<String> contents = dialog.getImportFileContent();
        ConfigParaHelp.performImportCmConf(server.getServerInfo(), contents);
    }
}
Also used : ImportConfigDialog(com.cubrid.cubridmanager.ui.host.dialog.ImportConfigDialog) CubridServer(com.cubrid.common.ui.spi.model.CubridServer)

Example 3 with ImportConfigDialog

use of com.cubrid.cubridmanager.ui.host.dialog.ImportConfigDialog in project cubrid-manager by CUBRID.

the class EditCMCubridBrokerConfPart method createToolBarComp.

/**
	 * create tool barcomp
	 * @param parent
	 */
public void createToolBarComp(Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    comp.setLayoutData(gd);
    GridLayout layout = new GridLayout(1, false);
    layout.marginHeight = -1;
    comp.setLayout(layout);
    ToolBar toolbar = new ToolBar(comp, SWT.LEFT_TO_RIGHT | SWT.FLAT);
    toolbar.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
    saveCubridBrokerConfItem = new ToolItem(toolbar, SWT.PUSH);
    saveCubridBrokerConfItem.setImage(CubridManagerUIPlugin.getImage("icons/queryeditor/file_save.png"));
    saveCubridBrokerConfItem.setToolTipText(com.cubrid.cubridmanager.ui.host.Messages.msgTipSaveAction);
    saveCubridBrokerConfItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            //check whether contains duplicate property name
            String errMsg = editorComp.validate();
            if (errMsg != null) {
                CommonUITool.openErrorBox(errMsg);
                return;
            }
            doSave();
        }
    });
    // Show/hide of the history pane
    saveAsCubridBrokerConfItem = new ToolItem(toolbar, SWT.PUSH);
    saveAsCubridBrokerConfItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/file_saveas.png"));
    saveAsCubridBrokerConfItem.setToolTipText(Messages.cubridBrokerConfEditorSaveAsItemLabel);
    saveAsCubridBrokerConfItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            //check whether contains duplicate property name
            String errMsg = editorComp.validate();
            if (errMsg != null) {
                CommonUITool.openErrorBox(errMsg);
                return;
            }
            ExportConfigDialog dialog = new ExportConfigDialog(getSite().getShell(), ConfigType.CUBRID_BROKER, true);
            if (defaultExportFilePath != null && !"".equals(defaultExportFilePath)) {
                dialog.setDefaultFilePath(defaultExportFilePath);
            }
            if (defaultExportFileName != null && !"".equals(defaultExportFileName)) {
                dialog.setDefaultFileName(defaultExportFileName);
            }
            if (defaultExportFileExtName != null && !"".equals(defaultExportFileExtName)) {
                dialog.setDefaultFileExtName(defaultExportFileExtName);
            }
            if (defaultExportFileCharset != null && !"".equals(defaultExportFileCharset)) {
                dialog.setOutputFileCharset(defaultExportFileCharset);
            }
            if (dialog.open() == Dialog.OK) {
                defaultExportFilePath = dialog.getDefaultFilePath();
                defaultExportFileName = dialog.getDefaultFileName();
                defaultExportFileExtName = dialog.getDefaultFileExtName();
                String fileFullName = dialog.getOutputFileFullName();
                defaultExportFileCharset = dialog.getOutputFileCharset();
                BrokerConfig cubridBrokerConfig = editorComp.getBrokerConfig();
                errMsg = editorComp.validate();
                if (errMsg != null) {
                    CommonUITool.openErrorBox(errMsg);
                    return;
                }
                String contents = brokerConfPersistUtil.readBrokerConfig(cubridBrokerConfig);
                try {
                    brokerConfPersistUtil.writeBrokerConfig(new File(fileFullName), defaultExportFileCharset, contents);
                    CommonUITool.openInformationBox(Messages.titleSuccess, Messages.cubridBrokerConfEditorSaveSucessMsg);
                    setDirty(false);
                } catch (Exception e) {
                    CommonUITool.openErrorBox(e.getMessage());
                }
            }
        }
    });
    new ToolItem(toolbar, SWT.SEPARATOR);
    ToolItem importItem = new ToolItem(toolbar, SWT.PUSH);
    importItem.setImage(CubridManagerUIPlugin.getImage("icons/queryeditor/file_open.png"));
    importItem.setToolTipText(com.cubrid.cubridmanager.ui.host.Messages.msgTipOpenAction);
    importItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            ImportConfigDialog dialog = new ImportConfigDialog(getSite().getShell(), ConfigType.CUBRID_BROKER, true);
            if (defaultImportFileName != null && !"".equals(defaultImportFileName)) {
                dialog.setDefaultFileName(defaultImportFileName);
            }
            if (defaultImportFileCharset != null && !"".equals(defaultImportFileCharset)) {
                dialog.setDefaultCharset(defaultImportFileCharset);
            }
            if (dialog.open() == Dialog.OK) {
                defaultImportFileName = dialog.getDefaultFileName();
                defaultImportFileCharset = dialog.getDefaultCharset();
                List<String> contents = dialog.getImportFileContent();
                StringBuilder contentBuilder = new StringBuilder();
                for (String content : contents) {
                    contentBuilder.append(content).append(StringUtil.NEWLINE);
                }
                BrokerConfig cubridBrokerConfig = brokerConfPersistUtil.parseStringLineToBrokerConfig(contentBuilder.toString());
                firstView = false;
                editorComp.setBrokerConfig(cubridBrokerConfig);
                editorComp.createBrokerConfTableData();
            }
        }
    });
    new ToolItem(toolbar, SWT.SEPARATOR);
    addPropItem = new ToolItem(toolbar, SWT.PUSH);
    addPropItem.setImage(CommonUIPlugin.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(CommonUIPlugin.getImage("icons/queryeditor/table_record_delete.png"));
    deletePropItem.setToolTipText(Messages.cubridBrokerConfEditorDeletePropItemLabel);
    deletePropItem.addSelectionListener(new SelectionAdapter() {

        @SuppressWarnings("all")
        public void widgetSelected(SelectionEvent event) {
            editorComp.deletePropData();
        }
    });
}
Also used : ExportConfigDialog(com.cubrid.cubridmanager.ui.host.dialog.ExportConfigDialog) BrokerConfig(com.cubrid.common.ui.spi.model.BrokerConfig) Composite(org.eclipse.swt.widgets.Composite) BrokerConfigEditComposite(com.cubrid.common.ui.common.control.BrokerConfigEditComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) PartInitException(org.eclipse.ui.PartInitException) GridLayout(org.eclipse.swt.layout.GridLayout) ImportConfigDialog(com.cubrid.cubridmanager.ui.host.dialog.ImportConfigDialog) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(java.util.List) File(java.io.File) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 4 with ImportConfigDialog

use of com.cubrid.cubridmanager.ui.host.dialog.ImportConfigDialog in project cubrid-manager by CUBRID.

the class EditConfigEditor method doImport.

/**
	 * Perform the import based upon the given ConfigType.
	 *
	 * @param configType the ConfigType
	 */
protected void doImport(ConfigType configType) {
    IEditorInput input = this.getEditorInput();
    if (!(input instanceof ConfEditInput)) {
        return;
    }
    ImportConfigDialog dialog = new ImportConfigDialog(this.getSite().getShell(), configType, true);
    if (defaultImportFileName != null && !"".equals(defaultImportFileName)) {
        dialog.setDefaultFileName(defaultImportFileName);
    }
    if (defaultImportFileCharset != null && !"".equals(defaultImportFileCharset)) {
        dialog.setDefaultCharset(defaultImportFileCharset);
    }
    if (dialog.open() == Dialog.OK) {
        defaultImportFileName = dialog.getDefaultFileName();
        defaultImportFileCharset = dialog.getDefaultCharset();
        contents = dialog.getImportFileContent();
        createContent();
    }
}
Also used : ConfEditInput(com.cubrid.cubridmanager.ui.host.action.ConfEditInput) ImportConfigDialog(com.cubrid.cubridmanager.ui.host.dialog.ImportConfigDialog) IEditorInput(org.eclipse.ui.IEditorInput)

Example 5 with ImportConfigDialog

use of com.cubrid.cubridmanager.ui.host.dialog.ImportConfigDialog in project cubrid-manager by CUBRID.

the class ImportHAConfigAction method run.

/**
	 * Open the importcm property dialog
	 */
public void run() {
    final Object[] obj = this.getSelectedObj();
    if (obj == null || obj.length <= 0) {
        setEnabled(false);
        return;
    }
    CubridServer server = (CubridServer) getSelectedObj()[0];
    ImportConfigDialog dialog = new ImportConfigDialog(getShell(), ConfigType.HA);
    if (dialog.open() == Dialog.OK) {
        List<String> contents = dialog.getImportFileContent();
        ConfigParaHelp.performImportHAConf(server.getServerInfo(), contents);
    }
}
Also used : ImportConfigDialog(com.cubrid.cubridmanager.ui.host.dialog.ImportConfigDialog) CubridServer(com.cubrid.common.ui.spi.model.CubridServer)

Aggregations

ImportConfigDialog (com.cubrid.cubridmanager.ui.host.dialog.ImportConfigDialog)6 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)4 BrokerConfigEditComposite (com.cubrid.common.ui.common.control.BrokerConfigEditComposite)1 BrokerConfig (com.cubrid.common.ui.spi.model.BrokerConfig)1 ConfEditInput (com.cubrid.cubridmanager.ui.host.action.ConfEditInput)1 ExportConfigDialog (com.cubrid.cubridmanager.ui.host.dialog.ExportConfigDialog)1 File (java.io.File)1 List (java.util.List)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 ToolBar (org.eclipse.swt.widgets.ToolBar)1 ToolItem (org.eclipse.swt.widgets.ToolItem)1 IEditorInput (org.eclipse.ui.IEditorInput)1 PartInitException (org.eclipse.ui.PartInitException)1