Search in sources :

Example 76 with FormLayout

use of org.eclipse.swt.layout.FormLayout in project cubrid-manager by CUBRID.

the class QueryRecordListComparator method createDialogArea.

/**
	 * Create dialog area content
	 *
	 * @param parent the parent composite
	 * @return the control
	 */
protected Control createDialogArea(Composite parent) {
    Composite container = new Composite(parent, SWT.None);
    container.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    container.setLayout(new FormLayout());
    topComposite = new Composite(container, SWT.None);
    FormData topData = new FormData();
    topData.top = new FormAttachment(0, 0);
    topData.bottom = new FormAttachment(0, 30);
    topData.left = new FormAttachment(0, 0);
    topData.right = new FormAttachment(100, 0);
    topComposite.setLayoutData(topData);
    topComposite.setLayout(new GridLayout(6, false));
    Label historyLable = new Label(topComposite, SWT.None);
    historyLable.setText(Messages.lblProject);
    historyLable.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    historyCombo = new Combo(topComposite, SWT.READ_ONLY);
    historyCombo.setLayoutData(CommonUITool.createGridData(1, 1, 200, -1));
    historyCombo.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            String name = historyCombo.getText();
            switchQueryRecordProject(name);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    ToolBar toolBar = new ToolBar(topComposite, SWT.None);
    toolBar.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
    addItem = new ToolItem(toolBar, SWT.PUSH);
    addItem.setImage(CommonUIPlugin.getImage("icons/queryplan/add_query.gif"));
    addItem.setToolTipText(Messages.itemTooltipAdd);
    addItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            addQueryRecordProject();
        }
    });
    deleteItem = new ToolItem(toolBar, SWT.PUSH);
    deleteItem.setImage(CommonUIPlugin.getImage("icons/queryplan/delete_query.gif"));
    deleteItem.setToolTipText(Messages.itemTooltipRemove);
    deleteItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
            if (queryRecordLeftCombo.getItemCount() == 0) {
                CommonUITool.openErrorBox(Messages.msgQueryTunerNotSavedProject);
                tabFolder.setSelection(0);
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            if (CommonUITool.openConfirmBox(Messages.confirmDeleteTuningProject)) {
                ApplicationPersistUtil.getInstance().removeQueryRecordProject(database.getDatabaseInfo(), historyCombo.getText());
                ApplicationPersistUtil.getInstance().save();
                switchQueryRecordProject("");
            }
        }
    });
    renameItem = new ToolItem(toolBar, SWT.PUSH);
    renameItem.setImage(CommonUIPlugin.getImage("icons/queryplan/rename_query.gif"));
    renameItem.setToolTipText(Messages.itemTooltipRename);
    renameItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            renameQueryRecordProject();
        }
    });
    Label placeHolderLabel = new Label(topComposite, SWT.None);
    placeHolderLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    buttomComposite = new Composite(container, SWT.None);
    buttomComposite.setLayout(new FillLayout());
    FormData buttomData = new FormData();
    buttomData.top = new FormAttachment(0, 30);
    buttomData.bottom = new FormAttachment(100, 0);
    buttomData.left = new FormAttachment(0, 0);
    buttomData.right = new FormAttachment(100, 0);
    buttomComposite.setLayoutData(buttomData);
    buttomComposite.setLayout(new FillLayout());
    tabFolder = new CTabFolder(buttomComposite, SWT.BORDER);
    tabFolder.setTabHeight(20);
    tabFolder.marginHeight = 5;
    tabFolder.marginWidth = 5;
    tabFolder.setMaximizeVisible(false);
    tabFolder.setMinimizeVisible(false);
    tabFolder.setSimple(false);
    tabFolder.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            if (tabFolder.getSelectionIndex() == 1) {
                List<QueryRecordProject> projectList = loadProjectList();
                if (projectList.size() == 0) {
                    CommonUITool.openErrorBox(Messages.msgQueryTunerNotSavedProject);
                    tabFolder.setSelection(0);
                } else {
                    QueryRecordProject usingProject = null;
                    String projectName = historyCombo.getText();
                    for (int i = 0; i < projectList.size(); i++) {
                        QueryRecordProject temp = projectList.get(i);
                        if (StringUtil.isEqual(projectName, temp.getName())) {
                            usingProject = temp;
                            break;
                        }
                    }
                    if (usingProject != null) {
                        if (usingProject.getQueryRecordList().size() == 0) {
                            CommonUITool.openErrorBox(Messages.errNoQueryInProject);
                            return;
                        }
                        switchQueryRecordProject(historyCombo.getText());
                    }
                }
            }
        }
    });
    createQueryTunerTab(tabFolder);
    createQueryCompareTab(tabFolder);
    init();
    return parent;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) CTabFolder(org.eclipse.swt.custom.CTabFolder) Composite(org.eclipse.swt.widgets.Composite) QueryPlanComposite(com.cubrid.common.ui.query.control.queryplan.QueryPlanComposite) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) FillLayout(org.eclipse.swt.layout.FillLayout) QueryRecordProject(com.cubrid.common.ui.query.tuner.QueryRecordProject) GridLayout(org.eclipse.swt.layout.GridLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ToolBar(org.eclipse.swt.widgets.ToolBar) ArrayList(java.util.ArrayList) List(java.util.List) FormAttachment(org.eclipse.swt.layout.FormAttachment) ToolItem(org.eclipse.swt.widgets.ToolItem) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 77 with FormLayout

use of org.eclipse.swt.layout.FormLayout in project cubrid-manager by CUBRID.

the class ExportTypePage method createControl.

/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
	 */
@Override
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    container.setLayout(new FormLayout());
    setTitle(Messages.titleExportStep1);
    setDescription(Messages.exportWizardTypeDescription);
    setControl(container);
    Composite leftComposite = new Composite(container, SWT.NONE);
    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, 0);
    GridLayout leftLayout = new GridLayout();
    leftLayout.verticalSpacing = 0;
    leftComposite.setLayout(leftLayout);
    leftComposite.setLayoutData(leftData);
    Composite rightComposite = new Composite(container, SWT.NONE);
    FormData rightData = new FormData();
    rightData.top = new FormAttachment(0, 5);
    rightData.bottom = new FormAttachment(100, 0);
    rightData.left = new FormAttachment(50, 0);
    rightData.right = new FormAttachment(100, -5);
    GridLayout rightLayout = new GridLayout();
    rightLayout.verticalSpacing = 0;
    rightComposite.setLayout(rightLayout);
    rightComposite.setLayoutData(rightData);
    fileButton = new Button(leftComposite, SWT.RADIO);
    fileButton.setText(Messages.exportWizardType1);
    fileButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    fileButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        public void widgetSelected(SelectionEvent e) {
            historyButton.setSelection(!fileButton.getSelection());
            loadDBButton.setSelection(!fileButton.getSelection());
            changeHistoryCompStatus();
        }
    });
    Group fileLabelGroup = new Group(leftComposite, SWT.None);
    fileLabelGroup.setLayoutData(CommonUITool.createGridData(1, 1, 370, 100));
    fileLabelGroup.setLayout(new FillLayout());
    Label fileLabel = new Label(fileLabelGroup, SWT.WRAP);
    fileLabel.setText(Messages.exportWizardTypeDescription1);
    Label separator1Label = new Label(leftComposite, SWT.None);
    separator1Label.setLayoutData(CommonUITool.createGridData(1, 1, 0, 20));
    historyButton = new Button(leftComposite, SWT.RADIO);
    historyButton.setText(Messages.exportWizardType3);
    historyButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    historyButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        public void widgetSelected(SelectionEvent e) {
            fileButton.setSelection(!historyButton.getSelection());
            loadDBButton.setSelection(!historyButton.getSelection());
            changeHistoryCompStatus();
            setPageComplete(true);
        }
    });
    Group historyLabelGroup = new Group(leftComposite, SWT.None);
    historyLabelGroup.setLayoutData(CommonUITool.createGridData(1, 1, 370, 100));
    historyLabelGroup.setLayout(new FillLayout());
    Label historyLabel = new Label(historyLabelGroup, SWT.WRAP);
    historyLabel.setText(Messages.exportWizardTypeDescription3);
    Composite historyComposite = new Composite(leftComposite, SWT.None);
    historyComposite.setLayout(new GridLayout(3, false));
    historyComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    historyCombo = new Combo(historyComposite, SWT.READ_ONLY);
    historyCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    historyCombo.setEnabled(false);
    historyCombo.addListener(SWT.Modify, new Listener() {

        public void handleEvent(Event event) {
            ExportConfig historyExportConfigModel = ExportConfigManager.getInstance().getConfig(historyCombo.getText());
            if (historyExportConfigModel != null) {
                ExportConfig exportConfigModel = cloneExportConfigModel(historyExportConfigModel);
                getExportDataWizardWizard().setConfigModel(exportConfigModel);
            }
            firePageStatusChanged(new StatusInfo(IStatus.INFO, ""));
            setPageComplete(true);
        }
    });
    final ExportConfigManager configManager = ExportConfigManager.getInstance();
    List<ExportConfig> configList = configManager.getAllConfigs();
    for (ExportConfig model : configList) {
        historyCombo.add(model.getName());
    }
    renameButton = new Button(historyComposite, SWT.None);
    renameButton.setText(Messages.btnRenameHistory);
    renameButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    renameButton.setEnabled(false);
    renameButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        public void widgetSelected(SelectionEvent e) {
            String historyName = historyCombo.getText();
            if (historyName == null || historyName.trim().length() == 0) {
                return;
            }
            ExportConfig model = configManager.getConfig(historyName);
            if (model == null) {
                return;
            }
            InputDialog dialog = new InputDialog(getShell(), Messages.titleExportRenameDialog, Messages.descExportRenameDialog, historyName, new IInputValidator() {

                public String isValid(String newText) {
                    if (newText == null || newText.trim().length() == 0) {
                        return Messages.msgExportRenamePleaseInputNewName;
                    }
                    if (configManager.getConfig(newText) != null) {
                        return Messages.msgExportRenameAlreadyExists;
                    }
                    return null;
                }
            });
            if (dialog.open() == IDialogConstants.OK_ID) {
                String newName = dialog.getValue();
                model.setName(newName);
                configManager.saveConfigs();
                historyCombo.remove(historyName);
                historyCombo.add(newName);
                historyCombo.setText(newName);
            }
        }
    });
    deleteButton = new Button(historyComposite, SWT.None);
    deleteButton.setText(Messages.btnDeleteHistory);
    deleteButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    deleteButton.setEnabled(false);
    deleteButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        public void widgetSelected(SelectionEvent e) {
            if (!CommonUITool.openConfirmBox(Messages.confirmDeleteExportHistory)) {
                return;
            }
            String historyName = historyCombo.getText();
            if (historyName == null || historyName.trim().length() == 0) {
                return;
            }
            configManager.removeConfig(configManager.getConfig(historyName));
            configManager.saveConfigs();
            historyCombo.remove(historyName);
        }
    });
    loadDBButton = new Button(rightComposite, SWT.RADIO);
    loadDBButton.setText(Messages.exportWizardType2);
    loadDBButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    loadDBButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        public void widgetSelected(SelectionEvent e) {
            fileButton.setSelection(!loadDBButton.getSelection());
            historyButton.setSelection(!loadDBButton.getSelection());
            changeHistoryCompStatus();
            historyButton.setSelection(false);
            fileButton.setSelection(false);
        }
    });
    Group loadDBLabelGroup = new Group(rightComposite, SWT.None);
    loadDBLabelGroup.setLayoutData(CommonUITool.createGridData(1, 1, 370, 100));
    loadDBLabelGroup.setLayout(new FillLayout());
    Label loadDBLabel = new Label(loadDBLabelGroup, SWT.WRAP);
    loadDBLabel.setText(Messages.exportWizardTypeDescription2);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Group(org.eclipse.swt.widgets.Group) Listener(org.eclipse.swt.widgets.Listener) SelectionListener(org.eclipse.swt.events.SelectionListener) InputDialog(org.eclipse.jface.dialogs.InputDialog) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) FillLayout(org.eclipse.swt.layout.FillLayout) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) StatusInfo(com.cubrid.common.ui.spi.StatusInfo) ExportConfig(com.cubrid.common.ui.cubrid.table.progress.ExportConfig) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Event(org.eclipse.swt.widgets.Event) PageChangedEvent(org.eclipse.jface.dialogs.PageChangedEvent) PageChangingEvent(org.eclipse.jface.dialogs.PageChangingEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) SelectionListener(org.eclipse.swt.events.SelectionListener) IInputValidator(org.eclipse.jface.dialogs.IInputValidator)

Example 78 with FormLayout

use of org.eclipse.swt.layout.FormLayout in project cubrid-manager by CUBRID.

the class ExportSettingPage method createControl.

@Override
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    container.setLayout(new FormLayout());
    setControl(container);
    Composite leftComposite = new Composite(container, SWT.NONE);
    leftComposite.setLayout(new GridLayout());
    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(45, 0);
    leftComposite.setLayoutData(leftData);
    Composite rightComposite = new Composite(container, SWT.NONE);
    FormData rightData = new FormData();
    rightData.top = new FormAttachment(0, 5);
    rightData.bottom = new FormAttachment(100, 0);
    rightData.left = new FormAttachment(45, 0);
    rightData.right = new FormAttachment(100, -5);
    rightComposite.setLayoutData(rightData);
    GridLayout rightCompositeLayout = new GridLayout();
    rightCompositeLayout.verticalSpacing = 10;
    rightComposite.setLayout(rightCompositeLayout);
    Label tableInfoLabel = new Label(leftComposite, SWT.None);
    tableInfoLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    tableInfoLabel.setText(Messages.exportWizardSourceTableLable);
    treeViewer = new CheckboxTreeViewer(leftComposite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    treeViewer.getTree().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    treeViewer.setContentProvider(new FilterTreeContentProvider());
    treeViewer.getTree().setLinesVisible(true);
    treeViewer.getTree().setHeaderVisible(true);
    treeViewer.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            updateDialogStatus(null);
        }
    });
    final TreeViewerColumn dbObjectCol = new TreeViewerColumn(treeViewer, SWT.NONE);
    dbObjectCol.setLabelProvider(new ExportObjectLabelProvider());
    final TreeViewerColumn whereCnd = new TreeViewerColumn(treeViewer, SWT.NONE);
    whereCnd.setLabelProvider(new ExportObjectLabelProvider());
    whereCnd.setEditingSupport(new EditingSupport(treeViewer) {

        TextCellEditor textCellEditor;

        protected boolean canEdit(Object element) {
            if (element instanceof ICubridNode) {
                ICubridNode node = (ICubridNode) element;
                if (node.getType() == NodeType.TABLE_COLUMN_FOLDER) {
                    return true;
                }
            }
            return false;
        }

        protected CellEditor getCellEditor(Object element) {
            if (textCellEditor == null) {
                textCellEditor = new TextCellEditor(treeViewer.getTree());
                textCellEditor.addListener(new ICellEditorListener() {

                    public void applyEditorValue() {
                    }

                    public void cancelEditor() {
                    }

                    public void editorValueChanged(boolean oldValidState, boolean newValidState) {
                    }
                });
            }
            return textCellEditor;
        }

        protected Object getValue(Object element) {
            final ICubridNode node = (ICubridNode) element;
            String condition = (String) node.getData(ExportObjectLabelProvider.CONDITION);
            if (condition == null) {
                return "";
            } else {
                return condition;
            }
        }

        protected void setValue(Object element, Object value) {
            final ICubridNode node = (ICubridNode) element;
            node.setData(ExportObjectLabelProvider.CONDITION, value);
            treeViewer.refresh();
            updateDialogStatus(null);
        }
    });
    dbObjectCol.getColumn().setWidth(160);
    dbObjectCol.getColumn().setText(Messages.tableLabel);
    whereCnd.getColumn().setWidth(120);
    whereCnd.getColumn().setText(Messages.conditionLabel);
    final Button selectAllBtn = new Button(leftComposite, SWT.CHECK);
    {
        selectAllBtn.setText(Messages.btnSelectAll);
        GridData gridData = new GridData();
        gridData.grabExcessHorizontalSpace = true;
        gridData.horizontalIndent = 0;
        gridData.horizontalSpan = 3;
        selectAllBtn.setLayoutData(gridData);
    }
    selectAllBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            boolean selection = selectAllBtn.getSelection();
            for (ICubridNode node : tablesOrViewLst) {
                treeViewer.setGrayed(node, false);
                treeViewer.setChecked(node, selection);
            }
            updateDialogStatus(null);
        }
    });
    /* Export content option */
    Group exportOptionGroup = new Group(rightComposite, SWT.None);
    exportOptionGroup.setText(Messages.exportWizardWhatExport);
    exportOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    RowLayout layout = new RowLayout();
    layout.spacing = 8;
    layout.marginWidth = 5;
    exportOptionGroup.setLayout(layout);
    schemaButton = new Button(exportOptionGroup, SWT.CHECK);
    schemaButton.setText(Messages.lblExportTargetSchema);
    schemaButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            boolean selection = schemaButton.getSelection();
            indexButton.setEnabled(selection);
            serialButton.setEnabled(selection);
            viewButton.setEnabled(selection);
            startValueButton.setEnabled(selection);
            updateDialogStatus(null);
        }
    });
    dataButton = new Button(exportOptionGroup, SWT.CHECK);
    dataButton.setText(Messages.lblExportTargetData);
    dataButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            updateDialogStatus(null);
            updateExportLobButtonStatus();
        }
    });
    indexButton = new Button(exportOptionGroup, SWT.CHECK);
    indexButton.setText(Messages.lblExportTargetIndex);
    serialButton = new Button(exportOptionGroup, SWT.CHECK);
    serialButton.setText(Messages.lblExportTargetSerial);
    viewButton = new Button(exportOptionGroup, SWT.CHECK);
    viewButton.setText(Messages.lblExportTargetView);
    exportLobButton = new Button(exportOptionGroup, SWT.CHECK);
    exportLobButton.setText(Messages.lblExportLobData);
    exportLobButton.setToolTipText(Messages.lblExportLobData);
    exportLobButton.setEnabled(false);
    startValueButton = new Button(exportOptionGroup, SWT.CHECK);
    startValueButton.setText(Messages.lblExportTargetStartValue);
    startValueButton.setToolTipText(Messages.tipExportTargetStartValue);
    /* Type group */
    Group typeOptionGroup = new Group(rightComposite, SWT.None);
    typeOptionGroup.setText(Messages.exportWizardWhereExport);
    typeOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    typeOptionGroup.setLayout(new GridLayout(2, false));
    Label typeLabel = new Label(typeOptionGroup, SWT.None);
    typeLabel.setText(Messages.exportWizardFileType);
    typeLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    Composite typeComposite = new Composite(typeOptionGroup, SWT.None);
    typeComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    typeComposite.setLayout(new GridLayout(6, false));
    sqlButton = new Button(typeComposite, SWT.RADIO);
    sqlButton.setText("SQL");
    sqlButton.setToolTipText("SQL");
    sqlButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    sqlButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            useFirstAsColumnBtn.setEnabled(false);
            setNullWidgetStatus(false);
            setDelimiterWidgetStatus(false);
            updateDialogStatus(null);
            updateExportLobButtonStatus();
        }
    });
    csvButton = new Button(typeComposite, SWT.RADIO);
    csvButton.setText("CSV");
    csvButton.setToolTipText("CSV");
    csvButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    csvButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            useFirstAsColumnBtn.setEnabled(true);
            setNullWidgetStatus(true);
            setDelimiterWidgetStatus(false);
            updateDialogStatus(null);
            updateExportLobButtonStatus();
        }
    });
    xlsButton = new Button(typeComposite, SWT.RADIO);
    xlsButton.setText("XLS");
    xlsButton.setToolTipText("XLS");
    xlsButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    xlsButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            useFirstAsColumnBtn.setEnabled(true);
            setNullWidgetStatus(true);
            setDelimiterWidgetStatus(false);
            updateDialogStatus(null);
            updateExportLobButtonStatus();
        }
    });
    xlsxButton = new Button(typeComposite, SWT.RADIO);
    xlsxButton.setText("XLSX");
    xlsxButton.setToolTipText("XLSX");
    xlsxButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    xlsxButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            useFirstAsColumnBtn.setEnabled(true);
            setNullWidgetStatus(true);
            setDelimiterWidgetStatus(false);
            updateDialogStatus(null);
            updateExportLobButtonStatus();
        }
    });
    txtButton = new Button(typeComposite, SWT.RADIO);
    txtButton.setText("TXT");
    txtButton.setToolTipText("TXT");
    txtButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    txtButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            useFirstAsColumnBtn.setEnabled(true);
            setNullWidgetStatus(true);
            setDelimiterWidgetStatus(true);
            updateDialogStatus(null);
            updateExportLobButtonStatus();
        }
    });
    obsButton = new Button(typeComposite, SWT.RADIO);
    obsButton.setText("OBS");
    obsButton.setToolTipText("OBS");
    obsButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    obsButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            useFirstAsColumnBtn.setEnabled(false);
            setNullWidgetStatus(false);
            setDelimiterWidgetStatus(false);
            updateDialogStatus(null);
            updateExportLobButtonStatus();
        }
    });
    Label pathLabel = new Label(typeOptionGroup, SWT.None);
    pathLabel.setText(Messages.exportWizardFilepath);
    pathLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    Composite fileComposite = new Composite(typeOptionGroup, SWT.None);
    fileComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    fileComposite.setLayout(new GridLayout(2, false));
    pathText = new Text(fileComposite, SWT.BORDER);
    pathText.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    pathText.setEditable(false);
    Button browseButton = new Button(fileComposite, SWT.None);
    browseButton.setText(Messages.btnBrowse);
    browseButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    browseButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            File savedDirFile = TableUtil.getSavedDir(getShell(), Messages.titleSelectFolderToBeExported, Messages.msgSelectFolderToBeExported, pathText.getText());
            if (savedDirFile != null) {
                String savePathString = null;
                String[] files = savedDirFile.list();
                String databaseName = getDatabase().getDatabaseInfo().getDbName();
                if (files != null && files.length > 0) {
                    String confirmMessage = Messages.bind(Messages.errorExportExistsFilesInFolder, databaseName);
                    boolean useCreate = CommonUITool.openConfirmBox(confirmMessage);
                    if (useCreate) {
                        File newFolder = new File(savedDirFile.getAbsolutePath() + File.separator + databaseName);
                        boolean existsDbNameFolder = newFolder.exists();
                        files = newFolder.list();
                        if (existsDbNameFolder && files != null && files.length > 0) {
                            String newFolderName = databaseName + "_" + DateUtil.getDatetimeStringOnNow("HHmmss");
                            savePathString = savedDirFile.getAbsolutePath() + File.separator + newFolderName;
                            String warnMessage = Messages.bind(Messages.errorExportExistsFilesInFolderWithRename, newFolderName);
                            CommonUITool.openWarningBox(warnMessage);
                        } else {
                            savePathString = savedDirFile.getAbsolutePath() + File.separator + databaseName;
                        }
                        new File(savePathString).mkdirs();
                    } else {
                        return;
                    }
                } else {
                    savePathString = savedDirFile.getAbsolutePath();
                }
                pathText.setText(savePathString);
            }
            updateDialogStatus(null);
        }
    });
    Group parsingGroup = new Group(rightComposite, SWT.None);
    parsingGroup.setText(Messages.exportWizardParsingOption);
    parsingGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    GridLayout parsingGroupLayout = new GridLayout(4, false);
    parsingGroupLayout.horizontalSpacing = 10;
    parsingGroup.setLayout(parsingGroupLayout);
    Label threadCountLabel = new Label(parsingGroup, SWT.None);
    threadCountLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    threadCountLabel.setText(Messages.lblThreadCount);
    threadCountSpinner = new Spinner(parsingGroup, SWT.BORDER | SWT.LEFT);
    threadCountSpinner.setValues(DEFAULT_EXPORT_THREAD_COUNT, MIN_EXPORT_THREAD_COUNT, MAX_EXPORT_THREAD_COUNT, 0, 1, 2);
    threadCountSpinner.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_FILL, 1, 1, -1, -1));
    Label emptyLabel = new Label(parsingGroup, SWT.None);
    emptyLabel.setLayoutData(CommonUITool.createGridData(2, 1, -1, -1));
    emptyLabel.setText("");
    Label dbCharsetLabel = new Label(parsingGroup, SWT.None);
    dbCharsetLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    dbCharsetLabel.setText(Messages.lblJDBCCharset);
    dbCharsetCombo = new Combo(parsingGroup, SWT.BORDER);
    dbCharsetCombo.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    dbCharsetCombo.setItems(QueryOptions.getAllCharset(null));
    dbCharsetCombo.setEnabled(false);
    Label fileCharsetLabel = new Label(parsingGroup, SWT.None);
    fileCharsetLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    fileCharsetLabel.setText(Messages.lblFileCharset);
    fileCharsetCombo = new Combo(parsingGroup, SWT.BORDER);
    fileCharsetCombo.setLayoutData(CommonUITool.createGridData(1, 1, -1, 21));
    fileCharsetCombo.setItems(QueryOptions.getAllCharset(null));
    Group dataOptionGroup = new Group(rightComposite, SWT.None);
    dataOptionGroup.setText(Messages.exportWizardDataOption);
    dataOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    dataOptionGroup.setLayout(new GridLayout(2, false));
    useFirstAsColumnBtn = new Button(dataOptionGroup, SWT.CHECK);
    {
        useFirstAsColumnBtn.setText(Messages.exportFirstLineFLAG);
        GridData gridData = new GridData();
        gridData.grabExcessHorizontalSpace = true;
        gridData.horizontalIndent = 0;
        gridData.horizontalSpan = 2;
        useFirstAsColumnBtn.setLayoutData(gridData);
        useFirstAsColumnBtn.setSelection(false);
    }
    Group delimiterOptionGroup = new Group(dataOptionGroup, SWT.None);
    delimiterOptionGroup.setText(Messages.exportWizardDelimiterOptions);
    delimiterOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    delimiterOptionGroup.setLayout(new GridLayout(2, false));
    Label columnLabel = new Label(delimiterOptionGroup, SWT.None);
    columnLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    columnLabel.setText(Messages.exportWizardColumnSeperator);
    columnDelimiterCombo = new Combo(delimiterOptionGroup, SWT.BORDER);
    columnDelimiterCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    columnDelimiterCombo.setTextLimit(32);
    columnDelimiterCombo.setItems(columnDelimeterName);
    columnDelimiterCombo.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            updateDialogStatus(null);
        }
    });
    Label rowLabel = new Label(delimiterOptionGroup, SWT.None);
    rowLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    rowLabel.setText(Messages.exportWizardRowSeperator);
    rowDelimiterCombo = new Combo(delimiterOptionGroup, SWT.BORDER);
    rowDelimiterCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    rowDelimiterCombo.setTextLimit(32);
    rowDelimiterCombo.setItems(rowDelimeterName);
    rowDelimiterCombo.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            updateDialogStatus(null);
        }
    });
    Group nullValueGroup = new Group(dataOptionGroup, SWT.None);
    nullValueGroup.setText(Messages.exportWizardNullOptions);
    nullValueGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    nullValueGroup.setLayout(new GridLayout(3, false));
    nullOneButton = new Button(nullValueGroup, SWT.RADIO);
    nullOneButton.setText("'NULL'");
    nullOneButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    nullTwoButton = new Button(nullValueGroup, SWT.RADIO);
    nullTwoButton.setText("'\\N'");
    nullTwoButton.setLayoutData(CommonUITool.createGridData(2, 1, -1, -1));
    nullThreeButton = new Button(nullValueGroup, SWT.RADIO);
    nullThreeButton.setText("'(NULL)'");
    nullThreeButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    otherButton = new Button(nullValueGroup, SWT.RADIO);
    otherButton.setText(Messages.btnOther);
    otherButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    otherButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            updateDialogStatus(null);
        }
    });
    otherText = new Text(nullValueGroup, SWT.BORDER);
    otherText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    otherText.setTextLimit(64);
    otherText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            updateDialogStatus(null);
        }
    });
    useFirstAsColumnBtn.setEnabled(false);
    setNullWidgetStatus(false);
    setDelimiterWidgetStatus(false);
}
Also used : Group(org.eclipse.swt.widgets.Group) ModifyListener(org.eclipse.swt.events.ModifyListener) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) Spinner(org.eclipse.swt.widgets.Spinner) Label(org.eclipse.swt.widgets.Label) EditingSupport(org.eclipse.jface.viewers.EditingSupport) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ICellEditorListener(org.eclipse.jface.viewers.ICellEditorListener) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) FilterTreeContentProvider(com.cubrid.common.ui.common.dialog.FilterTreeContentProvider) ExportObjectLabelProvider(com.cubrid.common.ui.common.navigator.ExportObjectLabelProvider) GridData(org.eclipse.swt.layout.GridData) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) File(java.io.File) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 79 with FormLayout

use of org.eclipse.swt.layout.FormLayout in project cubrid-manager by CUBRID.

the class ImportSettingTxtPage 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);
    mappingComposite = new FileToTableMappingComposite(container, SWT.NONE, database, this);
    mappingComposite.addSelectionChangedListener(this);
    mappingComposite.setLayout(new GridLayout());
    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(55, 0);
    mappingComposite.setLayoutData(leftData);
    Composite rightComposite = new Composite(container, SWT.NONE);
    FormData rightData = new FormData();
    rightData.top = new FormAttachment(0, 5);
    rightData.bottom = new FormAttachment(100, 0);
    rightData.left = new FormAttachment(55, 0);
    rightData.right = new FormAttachment(100, -5);
    rightComposite.setLayoutData(rightData);
    GridLayout rightCompositeLayout = new GridLayout();
    rightCompositeLayout.verticalSpacing = 10;
    rightComposite.setLayout(rightCompositeLayout);
    Group dataOptionGroup = new Group(rightComposite, SWT.None);
    dataOptionGroup.setText(Messages.grpDataOptions);
    dataOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    dataOptionGroup.setLayout(new GridLayout(2, false));
    Group nullValueGroup = new Group(dataOptionGroup, SWT.None);
    nullValueGroup.setText(Messages.grpNulls);
    nullValueGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    nullValueGroup.setLayout(new GridLayout(3, false));
    nullOneButton = new Button(nullValueGroup, SWT.CHECK);
    nullOneButton.setText("'NULL'");
    nullOneButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    nullTwoButton = new Button(nullValueGroup, SWT.CHECK);
    nullTwoButton.setText("'\\N'");
    nullTwoButton.setLayoutData(CommonUITool.createGridData(2, 1, -1, -1));
    nullThreeButton = new Button(nullValueGroup, SWT.CHECK);
    nullThreeButton.setText("'(NULL)'");
    nullThreeButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    otherButton = new Button(nullValueGroup, SWT.CHECK);
    otherButton.setText(Messages.btnOther);
    otherButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    otherButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            otherText.setEnabled(otherButton.getSelection());
        }
    });
    otherText = new Text(nullValueGroup, SWT.BORDER);
    otherText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    otherText.setTextLimit(64);
    otherText.setEnabled(false);
    Group delimiterOptionGroup = new Group(dataOptionGroup, SWT.None);
    delimiterOptionGroup.setText(Messages.grpDelimiter);
    delimiterOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    delimiterOptionGroup.setLayout(new GridLayout(2, false));
    Label columnLabel = new Label(delimiterOptionGroup, SWT.None);
    columnLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
    columnLabel.setText(Messages.lblCol);
    columnDelimiterCombo = new Combo(delimiterOptionGroup, SWT.BORDER);
    columnDelimiterCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    columnDelimiterCombo.setTextLimit(32);
    columnDelimiterCombo.setItems(columnDelimeterName);
    columnDelimiterCombo.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            if (columnDelimiterCombo.getText().length() == 0) {
                setErrorMessage(Messages.msgErrorSeparatorEmpty);
                return;
            }
            if (columnDelimiterCombo.getText().indexOf("\"") >= 0 || columnDelimiterCombo.getText().indexOf("\n") >= 0) {
                setErrorMessage(Messages.errorSeparatorInvalid);
                return;
            }
            ImportConfig importConfig = getImportDataWizard().getImportConfig();
            if (!getColumnDelimeter().equals(importConfig.getColumnDelimiter())) {
                mappingComposite.resetMapResult();
                validate();
            }
            getImportDataWizard().getImportConfig().setColumnDelimiter(getColumnDelimeter());
            setErrorMessage(null);
        }
    });
    Label rowLabel = new Label(delimiterOptionGroup, SWT.None);
    rowLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
    rowLabel.setText(Messages.lblRow);
    rowDelimiterCombo = new Combo(delimiterOptionGroup, SWT.BORDER);
    rowDelimiterCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    rowDelimiterCombo.setTextLimit(32);
    rowDelimiterCombo.setItems(rowDelimeterName);
    rowDelimiterCombo.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            if (rowDelimiterCombo.getText().length() == 0) {
                setErrorMessage(Messages.msgErrorSeparatorEmpty);
                return;
            }
            if (rowDelimiterCombo.getText().indexOf("\"") >= 0) {
                setErrorMessage(Messages.errorSeparatorInvalid);
                return;
            }
            ImportConfig importConfig = getImportDataWizard().getImportConfig();
            if (!getRowdelimeter().equals(importConfig.getRowDelimiter())) {
                mappingComposite.resetMapResult();
                validate();
            }
            getImportDataWizard().getImportConfig().setRowDelimiter(getRowdelimeter());
            setErrorMessage(null);
        }
    });
    Composite errorComposite = new Composite(dataOptionGroup, SWT.None);
    errorComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
    errorComposite.setLayout(new GridLayout(3, false));
    Label errorLabel = new Label(errorComposite, SWT.None);
    errorLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
    errorLabel.setText(Messages.lblErrorHandle);
    ignoreButton = new Button(errorComposite, SWT.RADIO);
    ignoreButton.setText(Messages.btnIgnoreSetToNull);
    ignoreButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    ignoreButton.setSelection(true);
    breakButton = new Button(errorComposite, SWT.RADIO);
    breakButton.setText(Messages.btnBreakImport);
    breakButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    Group enCodingOptionGroup = new Group(rightComposite, SWT.None);
    enCodingOptionGroup.setText(Messages.grpEncodingOption);
    enCodingOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    enCodingOptionGroup.setLayout(new GridLayout(4, false));
    Label dbCharsetLabel = new Label(enCodingOptionGroup, SWT.None);
    dbCharsetLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
    dbCharsetLabel.setText(Messages.lblDBCharset);
    dbCharsetCombo = new Combo(enCodingOptionGroup, SWT.BORDER);
    dbCharsetCombo.setLayoutData(CommonUITool.createGridData(1, 1, 50, 21));
    dbCharsetCombo.setEnabled(false);
    Label fileCharsetLabel = new Label(enCodingOptionGroup, SWT.None);
    fileCharsetLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
    fileCharsetLabel.setText(Messages.lblFileCharset);
    fileCharsetCombo = new Combo(enCodingOptionGroup, SWT.BORDER);
    fileCharsetCombo.setLayoutData(CommonUITool.createGridData(1, 1, 50, 21));
    fileCharsetCombo.setItems(QueryOptions.getAllCharset(null));
    fileCharsetCombo.select(0);
    fileCharsetCombo.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            getImportDataWizard().getImportConfig().setFilesCharset(fileCharsetCombo.getText());
        }
    });
    Group importOptionGroup = new Group(rightComposite, SWT.None);
    importOptionGroup.setText(Messages.grpImportOptions);
    importOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    importOptionGroup.setLayout(new GridLayout(2, false));
    Label lineLabel = new Label(importOptionGroup, SWT.None);
    lineLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
    lineLabel.setText(Messages.lblTotalLine);
    lineText = new Text(importOptionGroup, SWT.BORDER);
    lineText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    lineText.setText("0");
    lineText.setEditable(false);
    Label threadCountLabel = new Label(importOptionGroup, SWT.None);
    threadCountLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
    threadCountLabel.setText(Messages.lblThreadNum);
    threadCountSpinner = new Spinner(importOptionGroup, SWT.BORDER);
    threadCountSpinner.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    threadCountSpinner.setMaximum(ImportConfig.MAX_IMPORT_THREAD_COUNT);
    threadCountSpinner.setMinimum(ImportConfig.MIN_IMPORT_THREAD_COUNT);
    threadCountSpinner.setSelection(ImportConfig.DEFAULT_IMPORT_THREAD_COUNT);
    Label commitCountLabel = new Label(importOptionGroup, SWT.None);
    commitCountLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
    commitCountLabel.setText(Messages.lblCommitCount);
    commitCountSpinner = new Spinner(importOptionGroup, SWT.BORDER);
    commitCountSpinner.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    commitCountSpinner.setMaximum(ImportConfig.MAX_IMPORT_COMMIT_COUNT);
    commitCountSpinner.setMinimum(ImportConfig.MIN_IMPORT_COMMIT_COUNT);
    commitCountSpinner.setIncrement(ImportConfig.IMPORT_COMMIT_STEP);
    commitCountSpinner.setSelection(ImportConfig.DEFAULT_IMPORT_COMMIT_COUNT);
    Group lobOptionGroup = new Group(rightComposite, SWT.None);
    lobOptionGroup.setText(Messages.grpLobOptions);
    lobOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    lobOptionGroup.setLayout(new GridLayout(2, false));
    importClobButton = new Button(lobOptionGroup, SWT.CHECK);
    importClobButton.setText(Messages.btnImportClob);
    importClobButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    importClobButton.setSelection(true);
    importBlobButton = new Button(lobOptionGroup, SWT.CHECK);
    importBlobButton.setText(Messages.btnImportBlob);
    importBlobButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    importBlobButton.setSelection(true);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) Spinner(org.eclipse.swt.widgets.Spinner) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 80 with FormLayout

use of org.eclipse.swt.layout.FormLayout in project cubrid-manager by CUBRID.

the class ImportSettingExcelPage 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);
    mappingComposite = new FileToTableMappingComposite(container, SWT.NONE, database, this);
    mappingComposite.addSelectionChangedListener(this);
    mappingComposite.setLayout(new GridLayout());
    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(55, 0);
    mappingComposite.setLayoutData(leftData);
    Composite rightComposite = new Composite(container, SWT.NONE);
    FormData rightData = new FormData();
    rightData.top = new FormAttachment(0, 5);
    rightData.bottom = new FormAttachment(100, 0);
    rightData.left = new FormAttachment(55, 0);
    rightData.right = new FormAttachment(100, -5);
    rightComposite.setLayoutData(rightData);
    GridLayout rightCompositeLayout = new GridLayout();
    rightCompositeLayout.verticalSpacing = 10;
    rightComposite.setLayout(rightCompositeLayout);
    Group dataOptionGroup = new Group(rightComposite, SWT.None);
    dataOptionGroup.setText(Messages.grpDataOptions);
    dataOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    dataOptionGroup.setLayout(new GridLayout(3, false));
    Group nullValueGroup = new Group(dataOptionGroup, SWT.None);
    nullValueGroup.setText(Messages.grpNulls);
    nullValueGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, -1));
    nullValueGroup.setLayout(new GridLayout(5, false));
    nullOneButton = new Button(nullValueGroup, SWT.CHECK);
    nullOneButton.setText("'NULL'");
    nullOneButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    nullTwoButton = new Button(nullValueGroup, SWT.CHECK);
    nullTwoButton.setText("'\\N'");
    nullTwoButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    nullThreeButton = new Button(nullValueGroup, SWT.CHECK);
    nullThreeButton.setText("'(NULL)'");
    nullThreeButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    otherButton = new Button(nullValueGroup, SWT.CHECK);
    otherButton.setText(Messages.btnOther);
    otherButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    otherButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            otherText.setEnabled(otherButton.getSelection());
        }
    });
    otherText = new Text(nullValueGroup, SWT.BORDER);
    otherText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    otherText.setTextLimit(64);
    otherText.setEnabled(false);
    Label errorLabel = new Label(dataOptionGroup, SWT.None);
    errorLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
    errorLabel.setText(Messages.lblErrorHandle);
    ignoreButton = new Button(dataOptionGroup, SWT.RADIO);
    ignoreButton.setText(Messages.btnIgnoreSetToNull);
    ignoreButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    ignoreButton.setSelection(true);
    breakButton = new Button(dataOptionGroup, SWT.RADIO);
    breakButton.setText(Messages.btnBreakImport);
    breakButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    Group enCodingOptionGroup = new Group(rightComposite, SWT.None);
    enCodingOptionGroup.setText(Messages.grpEncodingOption);
    enCodingOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    enCodingOptionGroup.setLayout(new GridLayout(4, false));
    Label dbCharsetLabel = new Label(enCodingOptionGroup, SWT.None);
    dbCharsetLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
    dbCharsetLabel.setText(Messages.lblDBCharset);
    dbCharsetCombo = new Combo(enCodingOptionGroup, SWT.BORDER);
    dbCharsetCombo.setLayoutData(CommonUITool.createGridData(1, 1, 50, 21));
    dbCharsetCombo.setEnabled(false);
    Label fileCharsetLabel = new Label(enCodingOptionGroup, SWT.None);
    fileCharsetLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
    fileCharsetLabel.setText(Messages.lblFileCharset);
    fileCharsetCombo = new Combo(enCodingOptionGroup, SWT.BORDER);
    fileCharsetCombo.setLayoutData(CommonUITool.createGridData(1, 1, 50, 21));
    fileCharsetCombo.setItems(QueryOptions.getAllCharset(null));
    fileCharsetCombo.select(0);
    fileCharsetCombo.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            getImportDataWizard().getImportConfig().setFilesCharset(fileCharsetCombo.getText());
        }
    });
    Group importOptionGroup = new Group(rightComposite, SWT.None);
    importOptionGroup.setText(Messages.grpImportOptions);
    importOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    importOptionGroup.setLayout(new GridLayout(2, false));
    Label lineLabel = new Label(importOptionGroup, SWT.None);
    lineLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
    lineLabel.setText(Messages.lblTotalLine);
    lineText = new Text(importOptionGroup, SWT.BORDER);
    lineText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    lineText.setText("0");
    lineText.setEditable(false);
    Label threadCountLabel = new Label(importOptionGroup, SWT.None);
    threadCountLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
    threadCountLabel.setText(Messages.lblThreadNum);
    threadCountSpinner = new Spinner(importOptionGroup, SWT.BORDER);
    threadCountSpinner.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    threadCountSpinner.setMaximum(ImportConfig.MAX_IMPORT_THREAD_COUNT);
    threadCountSpinner.setMinimum(ImportConfig.MIN_IMPORT_THREAD_COUNT);
    threadCountSpinner.setSelection(ImportConfig.DEFAULT_IMPORT_THREAD_COUNT);
    Label commitCountLabel = new Label(importOptionGroup, SWT.None);
    commitCountLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
    commitCountLabel.setText(Messages.lblCommitCount);
    commitCountSpinner = new Spinner(importOptionGroup, SWT.BORDER);
    commitCountSpinner.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    commitCountSpinner.setMaximum(ImportConfig.MAX_IMPORT_COMMIT_COUNT);
    commitCountSpinner.setMinimum(ImportConfig.MIN_IMPORT_COMMIT_COUNT);
    commitCountSpinner.setIncrement(ImportConfig.IMPORT_COMMIT_STEP);
    commitCountSpinner.setSelection(ImportConfig.DEFAULT_IMPORT_COMMIT_COUNT);
    Group lobOptionGroup = new Group(rightComposite, SWT.None);
    lobOptionGroup.setText(Messages.grpLobOptions);
    lobOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    lobOptionGroup.setLayout(new GridLayout(2, false));
    importClobButton = new Button(lobOptionGroup, SWT.CHECK);
    importClobButton.setText(Messages.btnImportClob);
    importClobButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    importClobButton.setSelection(true);
    importBlobButton = new Button(lobOptionGroup, SWT.CHECK);
    importBlobButton.setText(Messages.btnImportBlob);
    importBlobButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    importBlobButton.setSelection(true);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) Spinner(org.eclipse.swt.widgets.Spinner) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

FormLayout (org.eclipse.swt.layout.FormLayout)127 FormData (org.eclipse.swt.layout.FormData)97 FormAttachment (org.eclipse.swt.layout.FormAttachment)93 Composite (org.eclipse.swt.widgets.Composite)82 Button (org.eclipse.swt.widgets.Button)54 Label (org.eclipse.swt.widgets.Label)53 SelectionEvent (org.eclipse.swt.events.SelectionEvent)39 Point (org.eclipse.swt.graphics.Point)33 Group (org.eclipse.swt.widgets.Group)31 GridData (org.eclipse.swt.layout.GridData)30 Text (org.eclipse.swt.widgets.Text)30 GridLayout (org.eclipse.swt.layout.GridLayout)29 SelectionListener (org.eclipse.swt.events.SelectionListener)27 Combo (org.eclipse.swt.widgets.Combo)25 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)19 FillLayout (org.eclipse.swt.layout.FillLayout)19 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)17 StyledText (org.eclipse.swt.custom.StyledText)13 ModifyListener (org.eclipse.swt.events.ModifyListener)12 ModifyEvent (org.eclipse.swt.events.ModifyEvent)11