提交 23f9e06c 编写于 作者: E Evgeny Fradkin

#1599 Mock data extension. Stub implementation.


Former-commit-id: a02c86e1
上级 b3a519f6
......@@ -49,5 +49,6 @@
<plugin id="org.jkiss.dbeaver.ext.import_config" download-size="0" install-size="0" version="0.0.0" unpack="false"/>
<plugin id="org.jkiss.dbeaver.ext.ui.locks" download-size="0" install-size="0" version="0.0.0" unpack="false"/>
<plugin id="org.jkiss.utils" download-size="0" install-size="0" version="0.0.0" unpack="false"/>
<plugin id="org.jkiss.dbeaver.ext.mockdata" download-size="0" install-size="0" version="0.0.0" unpack="false"/>
</feature>
......@@ -68,6 +68,7 @@ public abstract class AbstractToolWizard<BASE_OBJECT extends DBSObject, PROCESS_
private String toolUserName;
private String toolUserPassword;
private String extraCommandArgs;
protected boolean clientHomeRequired = true;
protected String task;
protected final DatabaseWizardPageLog logPage;
......@@ -161,16 +162,18 @@ public abstract class AbstractToolWizard<BASE_OBJECT extends DBSObject, PROCESS_
WizardPage currentPage = (WizardPage) getStartingPage();
String clientHomeId = connectionInfo.getClientHomeId();
if (clientHomeId == null) {
currentPage.setErrorMessage(CoreMessages.tools_wizard_message_no_client_home);
getContainer().updateMessage();
return;
}
clientHome = findServerHome(clientHomeId);//MySQLDataSourceProvider.getServerHome(clientHomeId);
if (clientHome == null) {
currentPage.setErrorMessage(NLS.bind(CoreMessages.tools_wizard_message_client_home_not_found, clientHomeId));
getContainer().updateMessage();
if (clientHomeRequired) {
String clientHomeId = connectionInfo.getClientHomeId();
if (clientHomeId == null) {
currentPage.setErrorMessage(CoreMessages.tools_wizard_message_no_client_home);
getContainer().updateMessage();
return;
}
clientHome = findServerHome(clientHomeId);//MySQLDataSourceProvider.getServerHome(clientHomeId);
if (clientHome == null) {
currentPage.setErrorMessage(NLS.bind(CoreMessages.tools_wizard_message_client_home_not_found, clientHomeId));
getContainer().updateMessage();
}
}
}
......
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.jkiss.dbeaver.ext.mockdata</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
#Thu Dec 30 16:00:50 MSK 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.jkiss.dbeaver.ext.mockdata;singleton:=true
Bundle-Version: 1.0.1
Bundle-Release-Date: 20171225
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.ui.views,
org.eclipse.jface,
org.eclipse.jface.text,
org.jkiss.dbeaver.core,
org.eclipse.ui.workbench.texteditor,
org.jkiss.dbeaver.ext.generic
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-Vendor: %Bundle-Vendor
Bundle-ClassPath: .
#Properties file for org.jkiss.dbeaver.ext.mockdata
Bundle-Vendor = JKISS
Bundle-Name = DBeaver Mock Data Support
\ No newline at end of file
source.. = src/
output.. = bin/
bin.includes = .,\
META-INF/,\
OSGI-INF/,\
plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
<extension point="org.jkiss.dbeaver.tools">
<tools>
<tool
class="org.jkiss.dbeaver.ext.mockdata.MockData"
description="Mock Data"
id="org.jkiss.dbeaver.ext.mockdata.MockData"
label="Mock Data"
singleton="false">
<objectType name="org.jkiss.dbeaver.model.struct.DBSDataManipulator" forceCheck="true"/>
</tool>
</tools>
</extension>
</plugin>
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jkiss.dbeaver</groupId>
<artifactId>dbeaver</artifactId>
<version>1.0.0</version>
<relativePath>../../</relativePath>
</parent>
<artifactId>org.jkiss.dbeaver.ext.mockdata</artifactId>
<version>0.0.1</version>
<packaging>eclipse-plugin</packaging>
</project>
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
* Copyright (C) 2010-2017 Eugene Fradkin (eugene.fradkin@gmail.com)
*
* 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.ext.mockdata;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.struct.DBSDataManipulator;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.dbeaver.tools.IExternalTool;
import org.jkiss.dbeaver.ui.dialogs.tools.ToolWizardDialog;
import java.util.ArrayList;
import java.util.Collection;
public class MockData implements IExternalTool {
public void execute(IWorkbenchWindow window, IWorkbenchPart activePart, Collection<DBSObject> objects) throws DBException {
ArrayList<DBSDataManipulator> dbObjects = new ArrayList<>();
for (DBSObject obj : objects) {
dbObjects.add((DBSDataManipulator) obj);
}
ToolWizardDialog dialog = new ToolWizardDialog(
window,
new MockDataExecuteWizard(dbObjects, MockDataMessages.tools_mockdata_wizard_page_name));
dialog.open();
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
* Copyright (C) 2010-2017 Eugene Fradkin (eugene.fradkin@gmail.com)
*
* 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.ext.mockdata;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IImportWizard;
import org.eclipse.ui.IWorkbench;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.connection.DBPClientHome;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.struct.DBSDataManipulator;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.dialogs.tools.AbstractToolWizard;
import org.jkiss.utils.CommonUtils;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
public class MockDataExecuteWizard extends AbstractToolWizard<DBSDataManipulator, DBSDataManipulator> implements IImportWizard{
private static final Log log = Log.getLog(MockDataExecuteWizard.class);
private MockDataWizardPageSettings settingsPage;
boolean removeOldData;
public MockDataExecuteWizard(Collection<DBSDataManipulator> dbObjects, String task) {
super(dbObjects, task);
this.clientHomeRequired = false;
}
@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
setWindowTitle(task);
setNeedsProgressMonitor(true);
settingsPage = new MockDataWizardPageSettings(this);
}
@Override
public void addPages() {
addPage(settingsPage);
addPage(logPage);
super.addPages();
}
/*
@Override
public IWizardPage getNextPage(IWizardPage page) {
if (page == settingsPage) {
return null;
}
return super.getNextPage(page);
}
@Override
public IWizardPage getPreviousPage(IWizardPage page) {
if (page == logPage) {
return settingsPage;
}
return super.getPreviousPage(page);
}
*/
@Override
public void onSuccess(long workTime) {
UIUtils.showMessageBox(
getShell(),
MockDataMessages.tools_mockdata_wizard_page_name,
CommonUtils.truncateString(NLS.bind(MockDataMessages.tools_mockdata_wizard_message_process_completed, getObjectsName()), 255),
SWT.ICON_INFORMATION);
//UIUtils.launchProgram(outputFolder.getAbsolutePath());
}
public DBPClientHome findServerHome(String clientHomeId) {
return null;
}
@Override
public Collection<DBSDataManipulator> getRunInfo() {
return getDatabaseObjects();
}
protected List<String> getCommandLine(DBSDataManipulator jdbcTable) throws IOException {
return null;
}
public void fillProcessParameters(List<String> cmd, DBSDataManipulator jdbcTable) throws IOException {
}
@Override
protected void startProcessHandler(DBRProgressMonitor monitor, DBSDataManipulator dbsDataManipulator, ProcessBuilder processBuilder, Process process) {
}
@Override
public void createPageControls(Composite pageContainer) {
super.createPageControls(pageContainer);
}
@Override
public boolean executeProcess(DBRProgressMonitor monitor, DBSDataManipulator arg)
throws IOException, CoreException, InterruptedException {
log.debug(">>>>>>>> executeProcess " + arg.getName());
logPage.appendLog("Remove old data " + removeOldData + "\n");
if (removeOldData) {
// TODO remove all old data
}
// TODO generate and insert the mock data to the table
logPage.appendLog("Generate and insert the mock data to the table " + arg.getName() + "\n\n");
return true;
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
* Copyright (C) 2010-2017 Eugene Fradkin (eugene.fradkin@gmail.com)
*
* 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.ext.mockdata;
import org.eclipse.osgi.util.NLS;
public class MockDataMessages extends NLS {
static final String BUNDLE_NAME = "org.jkiss.dbeaver.ext.mockdata.MockDataResources"; //$NON-NLS-1$
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, MockDataMessages.class);
}
public MockDataMessages() {
}
public static String tools_mockdata_wizard_page_name;
public static String tools_mockdata_wizard_page_settings_group_settings;
public static String tools_mockdata_wizard_page_settings_page_name;
public static String tools_mockdata_wizard_page_settings_page_description;
public static String tools_mockdata_wizard_page_settings_checkbox_remove_old_data;
public static String tools_mockdata_wizard_message_process_completed;
}
tools_mockdata_wizard_page_name=Mock Data
tools_mockdata_wizard_message_process_completed="{0}" Mock data process completed
tools_mockdata_wizard_page_settings_group_settings=Settings
tools_mockdata_wizard_page_settings_page_name=Mock Data configuration
tools_mockdata_wizard_page_settings_page_description=Set Mock Data settings
tools_mockdata_wizard_page_settings_checkbox_remove_old_data=Remove Old Data
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
* Copyright (C) 2010-2017 Eugene Fradkin (eugene.fradkin@gmail.com)
*
* 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.ext.mockdata;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.dialogs.tools.AbstractToolWizardPage;
public class MockDataWizardPageSettings extends AbstractToolWizardPage<MockDataExecuteWizard>
{
private Button removeOldDataCheck;
protected MockDataWizardPageSettings(MockDataExecuteWizard wizard)
{
super(wizard, MockDataMessages.tools_mockdata_wizard_page_settings_page_name);
setTitle(MockDataMessages.tools_mockdata_wizard_page_settings_page_name);
setDescription((MockDataMessages.tools_mockdata_wizard_page_settings_page_description));
}
public void createControl(Composite parent)
{
Composite composite = UIUtils.createPlaceholder(parent, 1);
SelectionListener changeListener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateState();
}
};
Group settingsGroup = UIUtils.createControlGroup(composite, MockDataMessages.tools_mockdata_wizard_page_settings_group_settings, 3, GridData.FILL_HORIZONTAL, 0);
removeOldDataCheck = UIUtils.createCheckbox(settingsGroup, MockDataMessages.tools_mockdata_wizard_page_settings_checkbox_remove_old_data, wizard.removeOldData);
removeOldDataCheck.addSelectionListener(changeListener);
setControl(composite);
}
private void updateState()
{
wizard.removeOldData = removeOldDataCheck.getSelection();
getContainer().updateButtons();
}
@Override
public boolean isPageComplete() {
return true;
}
}
......@@ -63,6 +63,7 @@
<module>plugins/org.jkiss.dbeaver.ext.ui.svg</module>
<module>plugins/org.jkiss.dbeaver.data.office</module>
<module>plugins/org.jkiss.dbeaver.model</module>
<module>plugins/org.jkiss.dbeaver.ext.mockdata</module>
<module>features/org.jkiss.dbeaver.core.feature</module>
<module>features/org.jkiss.dbeaver.debug.feature</module>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册