/* * DBeaver - Universal Database Manager * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jkiss.dbeaver.tools.transfer.database; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Spinner; import org.jkiss.dbeaver.core.CoreMessages; import org.jkiss.dbeaver.tools.transfer.wizard.DataTransferWizard; import org.jkiss.dbeaver.ui.UIUtils; import org.jkiss.dbeaver.ui.dialogs.ActiveWizardPage; public class DatabaseConsumerPageLoadSettings extends ActiveWizardPage<DataTransferWizard> { public DatabaseConsumerPageLoadSettings() { super("Data load"); setTitle("Data load settings"); setDescription("Configuration of table data load"); setPageComplete(false); } @Override public void createControl(Composite parent) { initializeDialogUnits(parent); Composite composite = new Composite(parent, SWT.NULL); GridLayout gl = new GridLayout(); gl.marginHeight = 0; gl.marginWidth = 0; composite.setLayout(gl); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); final DatabaseConsumerSettings settings = getWizard().getPageSettings(this, DatabaseConsumerSettings.class); { Group performanceSettings = UIUtils.createControlGroup(composite, "Performance", 4, GridData.FILL_HORIZONTAL, 0); final Button newConnectionCheckbox = UIUtils.createLabelCheckbox( performanceSettings, CoreMessages.data_transfer_wizard_output_checkbox_new_connection, settings.isOpenNewConnections()); newConnectionCheckbox.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { settings.setOpenNewConnections(newConnectionCheckbox.getSelection()); } }); newConnectionCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, false, false, 3, 1)); final Button useTransactionsCheck = UIUtils.createLabelCheckbox(performanceSettings, "Use transactions", settings.isUseTransactions()); useTransactionsCheck.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { settings.setUseTransactions(useTransactionsCheck.getSelection()); } }); useTransactionsCheck.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, false, false, 3, 1)); final Spinner commitAfterEdit = UIUtils.createLabelSpinner(performanceSettings, "Commit after insert of ", settings.getCommitAfterRows(), 1, Integer.MAX_VALUE); commitAfterEdit.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { settings.setCommitAfterRows(commitAfterEdit.getSelection()); } }); commitAfterEdit.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, false, false, 3, 1)); } { Group generalSettings = UIUtils.createControlGroup(composite, "General", 4, GridData.FILL_HORIZONTAL, 0); final Button showTableCheckbox = UIUtils.createLabelCheckbox(generalSettings, "Open table editor on finish", settings.isOpenTableOnFinish()); showTableCheckbox.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { settings.setOpenTableOnFinish(showTableCheckbox.getSelection()); } }); showTableCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, false, false, 3, 1)); } setControl(composite); } @Override public void activatePage() { final DatabaseConsumerSettings settings = getWizard().getPageSettings(this, DatabaseConsumerSettings.class); updatePageCompletion(); } @Override protected boolean determinePageCompletion() { return true; } }