提交 28c5908b 编写于 作者: S serge-rider

Compare plugins extraction


Former-commit-id: a16a23b3
上级 ec17e798
......@@ -66,6 +66,10 @@
<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.format.sqlworkbenchj" download-size="0" install-size="0" version="0.0.0" unpack="false"/>
<!-- Compare -->
<plugin id="org.jkiss.dbeaver.cmp.simple" download-size="0" install-size="0" version="0.0.0" unpack="false"/>
<plugin id="org.jkiss.dbeaver.cmp.simple.ui" download-size="0" install-size="0" version="0.0.0" unpack="false"/>
<!-- Gis -->
<plugin id="org.jkiss.bundle.gis" download-size="0" install-size="0" version="0.0.0" unpack="false"/>
<plugin id="org.jkiss.dbeaver.data.gis" download-size="0" install-size="0" version="0.0.0" unpack="false"/>
......
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Vendor: %Bundle-Vendor
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.jkiss.dbeaver.cmp.simple.ui;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Release-Date: 20190422
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.jkiss.dbeaver.tools.compare.simple.ui
Bundle-ClassPath: .
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui,
org.eclipse.ui.views,
org.eclipse.ui.workbench,
org.eclipse.ui.ide,
org.eclipse.swt,
org.eclipse.jface,
org.eclipse.jface.text,
org.jkiss.dbeaver.model,
org.jkiss.dbeaver.registry,
org.jkiss.dbeaver.ui,
org.jkiss.dbeaver.ui.editors.sql,
org.jkiss.dbeaver.ui.navigator,
org.jkiss.dbeaver.cmp.simple,
org.jkiss.utils
Bundle-Localization: OSGI-INF/l10n/bundle
command.org.jkiss.dbeaver.core.compare.objects.name=Compare
command.org.jkiss.dbeaver.core.compare.objects.description=Compare database objects
command.org.jkiss.dbeaver.core.compare.objects.description = Datenbankobjekte vergleichen
command.org.jkiss.dbeaver.core.compare.objects.name = Vergleichen
command.org.jkiss.dbeaver.core.compare.objects.description = Comparer des objets base de donn\u00E9es
command.org.jkiss.dbeaver.core.compare.objects.name = Comparer
command.org.jkiss.dbeaver.core.compare.objects.name=\u6BD4\u8F03
command.org.jkiss.dbeaver.core.compare.objects.description=\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u306E\u6BD4\u8F03
command.org.jkiss.dbeaver.core.compare.objects.name=\uBE44\uAD50
command.org.jkiss.dbeaver.core.compare.objects.description=\uB370\uC774\uD130\uBCA0\uC774\uC2A4 \uBE44\uAD50
command.org.jkiss.dbeaver.core.compare.objects.description = \u0421\u0440\u0430\u0432\u043D\u0438\u0442\u044C \u043E\u0431\u044A\u0435\u043A\u0442\u044B \u0411\u0414
command.org.jkiss.dbeaver.core.compare.objects.name = \u0421\u0440\u0430\u0432\u043D\u0438\u0442\u044C
command.org.jkiss.dbeaver.core.compare.objects.description = \u6BD4\u8F83\u6570\u636E\u5E93\u5BF9\u8C61
command.org.jkiss.dbeaver.core.compare.objects.name = \u6BD4\u8F83
source.. = src/
output.. = target/classes/
bin.includes = .,\
META-INF/,\
OSGI-INF/,\
plugin.xml
jars.compile.order = .
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
<extension point="org.eclipse.ui.commands">
<command id="org.jkiss.dbeaver.core.compare.objects" name="%command.org.jkiss.dbeaver.core.compare.objects.name" description="%command.org.jkiss.dbeaver.core.compare.objects.description" categoryId="org.jkiss.dbeaver.core.util"/>
</extension>
<extension point="org.eclipse.ui.commandImages">
<image commandId="org.jkiss.dbeaver.core.compare.objects" icon="platform:/plugin/org.jkiss.dbeaver.ui/icons/file/compare.png"/>
</extension>
<extension point="org.eclipse.ui.handlers">
<handler commandId="org.jkiss.dbeaver.core.compare.objects" class="org.jkiss.dbeaver.tools.compare.simple.ui.CompareObjectsHandler">
<enabledWhen>
<with variable="selection">
<count value="+"/>
<iterate operator="and">
<adapt type="org.jkiss.dbeaver.model.navigator.DBNDatabaseNode"/>
</iterate>
</with>
</enabledWhen>
</handler>
</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>plugins</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>org.jkiss.dbeaver.cmp.simple.ui</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 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.compare;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseFolder;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode;
import org.jkiss.dbeaver.model.navigator.meta.DBXTreeNode;
import org.jkiss.dbeaver.runtime.DBWorkbench;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class CompareObjectsHandler extends AbstractHandler {
private static final Log log = Log.getLog(CompareObjectsHandler.class);
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
final ISelection selection = HandlerUtil.getCurrentSelection(event);
if (!(selection instanceof IStructuredSelection)) {
return null;
}
IStructuredSelection ss = (IStructuredSelection)selection;
if (ss.size() < 2) {
log.error("At least 2 objects must be selected to perform compare");
return null;
}
List<DBNDatabaseNode> nodes = new ArrayList<>();
Class<?> firstType = null;
DBXTreeNode firstMeta = null;
for (Iterator<?> iter = ss.iterator(); iter.hasNext(); ) {
DBNDatabaseNode node = (DBNDatabaseNode) iter.next();
DBXTreeNode meta = null;
if (node instanceof DBNDatabaseFolder) {
meta = node.getMeta();
if (firstMeta == null) {
firstMeta = meta;
}
}
if (node.getObject() == null) {
log.error("Bad node with null object");
return null;
}
Class<?> itemType = node.getObject().getClass();
if (firstType == null) {
firstType = itemType;
} else {
if (firstType != itemType || firstMeta != meta) {
DBWorkbench.getPlatformUI().showError("Different object types", "Objects of different types were selected. You may compare only objects of the same type");
return null;
}
}
nodes.add(node);
}
CompareWizardDialog dialog = new CompareWizardDialog(
workbenchWindow,
new CompareObjectsWizard(nodes));
dialog.open();
return null;
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 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.compare.simple.ui;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseFolder;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode;
import org.jkiss.dbeaver.model.navigator.meta.DBXTreeNode;
import org.jkiss.dbeaver.runtime.DBWorkbench;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class CompareObjectsHandler extends AbstractHandler {
private static final Log log = Log.getLog(CompareObjectsHandler.class);
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
final ISelection selection = HandlerUtil.getCurrentSelection(event);
if (!(selection instanceof IStructuredSelection)) {
return null;
}
IStructuredSelection ss = (IStructuredSelection)selection;
if (ss.size() < 2) {
log.error("At least 2 objects must be selected to perform compare");
return null;
}
List<DBNDatabaseNode> nodes = new ArrayList<>();
Class<?> firstType = null;
DBXTreeNode firstMeta = null;
for (Iterator<?> iter = ss.iterator(); iter.hasNext(); ) {
DBNDatabaseNode node = (DBNDatabaseNode) iter.next();
DBXTreeNode meta = null;
if (node instanceof DBNDatabaseFolder) {
meta = node.getMeta();
if (firstMeta == null) {
firstMeta = meta;
}
}
if (node.getObject() == null) {
log.error("Bad node with null object");
return null;
}
Class<?> itemType = node.getObject().getClass();
if (firstType == null) {
firstType = itemType;
} else {
if (firstType != itemType || firstMeta != meta) {
DBWorkbench.getPlatformUI().showError("Different object types", "Objects of different types were selected. You may compare only objects of the same type");
return null;
}
}
nodes.add(node);
}
CompareWizardDialog dialog = new CompareWizardDialog(
workbenchWindow,
new CompareObjectsWizard(nodes));
dialog.open();
return null;
}
}
\ No newline at end of file
......@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.tools.compare;
package org.jkiss.dbeaver.tools.compare.simple.ui;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
......@@ -24,6 +24,7 @@ import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.jkiss.dbeaver.tools.compare.simple.CompareObjectsSettings;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.dialogs.ActiveWizardPage;
import org.jkiss.dbeaver.ui.dialogs.DialogUtils;
......
......@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.tools.compare;
package org.jkiss.dbeaver.tools.compare.simple.ui;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
......@@ -23,6 +23,7 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode;
import org.jkiss.dbeaver.tools.compare.simple.CompareObjectsSettings;
import org.jkiss.dbeaver.ui.DBeaverIcons;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.dialogs.ActiveWizardPage;
......
......@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.tools.compare;
package org.jkiss.dbeaver.tools.compare.simple.ui;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.IStructuredSelection;
......@@ -28,6 +28,10 @@ import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress;
import org.jkiss.dbeaver.tools.compare.simple.CompareObjectsExecutor;
import org.jkiss.dbeaver.tools.compare.simple.CompareObjectsSettings;
import org.jkiss.dbeaver.tools.compare.simple.CompareReport;
import org.jkiss.dbeaver.tools.compare.simple.CompareReportRenderer;
import org.jkiss.dbeaver.ui.DialogSettingsDelegate;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.dialogs.DialogUtils;
......
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)
* Copyright (C) 2011-2012 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.tools.compare;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbenchWindow;
import org.jkiss.dbeaver.ui.dialogs.ActiveWizardDialog;
/**
* Compare wizard dialog
*/
public class CompareWizardDialog extends ActiveWizardDialog
{
public CompareWizardDialog(IWorkbenchWindow window, IWizard wizard)
{
super(window, wizard);
//setTitleImage(DBIcon.COMPARE.getImage());
}
@Override
protected void createButtonsForButtonBar(Composite parent)
{
super.createButtonsForButtonBar(parent);
Button finishButton = getButton(IDialogConstants.FINISH_ID);
finishButton.setText("Compare");
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)
* Copyright (C) 2011-2012 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.tools.compare.simple.ui;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbenchWindow;
import org.jkiss.dbeaver.ui.dialogs.ActiveWizardDialog;
/**
* Compare wizard dialog
*/
public class CompareWizardDialog extends ActiveWizardDialog
{
public CompareWizardDialog(IWorkbenchWindow window, IWizard wizard)
{
super(window, wizard);
//setTitleImage(DBIcon.COMPARE.getImage());
}
@Override
protected void createButtonsForButtonBar(Composite parent)
{
super.createButtonsForButtonBar(parent);
Button finishButton = getButton(IDialogConstants.FINISH_ID);
finishButton.setText("Compare");
}
}
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Vendor: %Bundle-Vendor
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.jkiss.dbeaver.cmp.simple;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Release-Date: 20190422
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.jkiss.dbeaver.tools.compare.simple
Bundle-ClassPath: .
Require-Bundle: org.eclipse.core.runtime,
org.jkiss.dbeaver.model;visibility:=reexport,
org.jkiss.dbeaver.registry;visibility:=reexport,
org.jkiss.utils;visibility:=reexport
Bundle-Localization: OSGI-INF/l10n/bundle
source.. = src/
output.. = target/classes/
bin.includes = .,\
META-INF/,\
OSGI-INF/,\
plugin.xml
jars.compile.order = .
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
</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>plugins</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>org.jkiss.dbeaver.cmp.simple</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 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.compare;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode;
import org.jkiss.dbeaver.model.preferences.DBPSettingsSection;
import java.util.List;
/**
* Compare settings
*/
public class CompareObjectsSettings {
public enum OutputType {
BROWSER("Open in browser"),
FILE("Save to file");
private final String title;
private OutputType(String title) {
this.title = title;
}
public String getTitle() {
return title;
}
}
private final List<DBNDatabaseNode> nodes;
private boolean skipSystemObjects = true;
private boolean compareLazyProperties = false;
private boolean compareOnlyStructure = false;
private boolean compareScripts = false;
private boolean showOnlyDifferences = false;
private OutputType outputType = OutputType.BROWSER;
private String outputFolder;
public CompareObjectsSettings(List<DBNDatabaseNode> nodes) {
this.nodes = nodes;
}
public List<DBNDatabaseNode> getNodes() {
return nodes;
}
public boolean isSkipSystemObjects() {
return skipSystemObjects;
}
public void setSkipSystemObjects(boolean skipSystemObjects) {
this.skipSystemObjects = skipSystemObjects;
}
public boolean isCompareLazyProperties() {
return compareLazyProperties;
}
public void setCompareLazyProperties(boolean compareLazyProperties) {
this.compareLazyProperties = compareLazyProperties;
}
public boolean isCompareOnlyStructure() {
return compareOnlyStructure;
}
public void setCompareOnlyStructure(boolean compareOnlyStructure) {
this.compareOnlyStructure = compareOnlyStructure;
}
public boolean isCompareScripts() {
return compareScripts;
}
public void setCompareScripts(boolean compareScripts) {
this.compareScripts = compareScripts;
}
public boolean isShowOnlyDifferences() {
return showOnlyDifferences;
}
public void setShowOnlyDifferences(boolean showOnlyDifferences) {
this.showOnlyDifferences = showOnlyDifferences;
}
public OutputType getOutputType() {
return outputType;
}
public void setOutputType(OutputType outputType) {
this.outputType = outputType;
}
public String getOutputFolder() {
return outputFolder;
}
public void setOutputFolder(String outputFolder) {
this.outputFolder = outputFolder;
}
void loadFrom(DBPSettingsSection dialogSettings) {
if (dialogSettings.get("skipSystem") != null) {
skipSystemObjects = dialogSettings.getBoolean("skipSystem");
}
if (dialogSettings.get("compareLazy") != null) {
compareLazyProperties = dialogSettings.getBoolean("compareLazy");
}
if (dialogSettings.get("compareStructure") != null) {
compareOnlyStructure = dialogSettings.getBoolean("compareStructure");
}
if (dialogSettings.get("showDifference") != null) {
showOnlyDifferences = dialogSettings.getBoolean("showDifference");
}
if (dialogSettings.get("compareScripts") != null) {
compareScripts = dialogSettings.getBoolean("compareScripts");
}
if (dialogSettings.get("outputType") != null) {
outputType = OutputType.valueOf(dialogSettings.get("outputType"));
}
if (dialogSettings.get("outputFolder") != null) {
outputFolder = dialogSettings.get("outputFolder");
}
}
void saveTo(DBPSettingsSection dialogSettings) {
dialogSettings.put("skipSystem", skipSystemObjects);
dialogSettings.put("compareLazy", compareLazyProperties);
dialogSettings.put("compareStructure", compareOnlyStructure);
dialogSettings.put("compareScripts", compareScripts);
dialogSettings.put("showDifference", showOnlyDifferences);
dialogSettings.put("outputType", outputType.name());
dialogSettings.put("outputFolder", outputFolder);
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 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.compare.simple;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode;
import org.jkiss.dbeaver.model.preferences.DBPSettingsSection;
import java.util.List;
/**
* Compare settings
*/
public class CompareObjectsSettings {
public enum OutputType {
BROWSER("Open in browser"),
FILE("Save to file");
private final String title;
private OutputType(String title) {
this.title = title;
}
public String getTitle() {
return title;
}
}
private final List<DBNDatabaseNode> nodes;
private boolean skipSystemObjects = true;
private boolean compareLazyProperties = false;
private boolean compareOnlyStructure = false;
private boolean compareScripts = false;
private boolean showOnlyDifferences = false;
private OutputType outputType = OutputType.BROWSER;
private String outputFolder;
public CompareObjectsSettings(List<DBNDatabaseNode> nodes) {
this.nodes = nodes;
}
public List<DBNDatabaseNode> getNodes() {
return nodes;
}
public boolean isSkipSystemObjects() {
return skipSystemObjects;
}
public void setSkipSystemObjects(boolean skipSystemObjects) {
this.skipSystemObjects = skipSystemObjects;
}
public boolean isCompareLazyProperties() {
return compareLazyProperties;
}
public void setCompareLazyProperties(boolean compareLazyProperties) {
this.compareLazyProperties = compareLazyProperties;
}
public boolean isCompareOnlyStructure() {
return compareOnlyStructure;
}
public void setCompareOnlyStructure(boolean compareOnlyStructure) {
this.compareOnlyStructure = compareOnlyStructure;
}
public boolean isCompareScripts() {
return compareScripts;
}
public void setCompareScripts(boolean compareScripts) {
this.compareScripts = compareScripts;
}
public boolean isShowOnlyDifferences() {
return showOnlyDifferences;
}
public void setShowOnlyDifferences(boolean showOnlyDifferences) {
this.showOnlyDifferences = showOnlyDifferences;
}
public OutputType getOutputType() {
return outputType;
}
public void setOutputType(OutputType outputType) {
this.outputType = outputType;
}
public String getOutputFolder() {
return outputFolder;
}
public void setOutputFolder(String outputFolder) {
this.outputFolder = outputFolder;
}
public void loadFrom(DBPSettingsSection dialogSettings) {
if (dialogSettings.get("skipSystem") != null) {
skipSystemObjects = dialogSettings.getBoolean("skipSystem");
}
if (dialogSettings.get("compareLazy") != null) {
compareLazyProperties = dialogSettings.getBoolean("compareLazy");
}
if (dialogSettings.get("compareStructure") != null) {
compareOnlyStructure = dialogSettings.getBoolean("compareStructure");
}
if (dialogSettings.get("showDifference") != null) {
showOnlyDifferences = dialogSettings.getBoolean("showDifference");
}
if (dialogSettings.get("compareScripts") != null) {
compareScripts = dialogSettings.getBoolean("compareScripts");
}
if (dialogSettings.get("outputType") != null) {
outputType = OutputType.valueOf(dialogSettings.get("outputType"));
}
if (dialogSettings.get("outputFolder") != null) {
outputFolder = dialogSettings.get("outputFolder");
}
}
public void saveTo(DBPSettingsSection dialogSettings) {
dialogSettings.put("skipSystem", skipSystemObjects);
dialogSettings.put("compareLazy", compareLazyProperties);
dialogSettings.put("compareStructure", compareOnlyStructure);
dialogSettings.put("compareScripts", compareScripts);
dialogSettings.put("showDifference", showOnlyDifferences);
dialogSettings.put("outputType", outputType.name());
dialogSettings.put("outputFolder", outputFolder);
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 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.compare;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode;
import java.util.List;
/**
* Report
*/
class CompareReport {
private List<DBNDatabaseNode> nodes;
private List<CompareReportLine> reportLines;
CompareReport(List<DBNDatabaseNode> nodes, List<CompareReportLine> reportLines)
{
this.nodes = nodes;
this.reportLines = reportLines;
}
public List<DBNDatabaseNode> getNodes()
{
return nodes;
}
public List<CompareReportLine> getReportLines()
{
return reportLines;
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 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.compare.simple;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode;
import java.util.List;
/**
* Report
*/
public class CompareReport {
private List<DBNDatabaseNode> nodes;
private List<CompareReportLine> reportLines;
CompareReport(List<DBNDatabaseNode> nodes, List<CompareReportLine> reportLines)
{
this.nodes = nodes;
this.reportLines = reportLines;
}
public List<DBNDatabaseNode> getNodes()
{
return nodes;
}
public List<CompareReportLine> getReportLines()
{
return reportLines;
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 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.compare;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode;
import java.util.List;
/**
* Report line
*/
class CompareReportLine {
DBNDatabaseNode structure;
DBNDatabaseNode[] nodes;
List<CompareReportProperty> properties;
int depth;
boolean hasDifference;
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 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.compare.simple;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode;
import java.util.List;
/**
* Report line
*/
class CompareReportLine {
DBNDatabaseNode structure;
DBNDatabaseNode[] nodes;
List<CompareReportProperty> properties;
int depth;
boolean hasDifference;
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 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.compare;
import org.jkiss.dbeaver.runtime.properties.ObjectPropertyDescriptor;
/**
* Report property
*/
class CompareReportProperty {
ObjectPropertyDescriptor property;
Object[] values;
public CompareReportProperty(ObjectPropertyDescriptor property)
{
this.property = property;
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 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.compare.simple;
import org.jkiss.dbeaver.runtime.properties.ObjectPropertyDescriptor;
/**
* Report property
*/
class CompareReportProperty {
ObjectPropertyDescriptor property;
Object[] values;
public CompareReportProperty(ObjectPropertyDescriptor property)
{
this.property = property;
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 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.compare;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseFolder;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.utils.GeneralUtils;
import org.jkiss.utils.CommonUtils;
import org.jkiss.utils.xml.XMLBuilder;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
public class CompareReportRenderer {
private CompareReport report;
private XMLBuilder xml;
private CompareObjectsSettings settings;
public void renderReport(DBRProgressMonitor monitor, CompareReport report, CompareObjectsSettings settings, OutputStream outputStream) throws IOException
{
this.report = report;
this.settings = settings;
this.xml = new XMLBuilder(outputStream, GeneralUtils.UTF8_ENCODING, true);
this.xml.setButify(true);
xml.addContent(
"<!DOCTYPE html \n" +
" PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n" +
" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
if (settings.isShowOnlyDifferences()) {
// Mark differences on tree nodes
List<CompareReportLine> reportLines = report.getReportLines();
int reportLinesSize = reportLines.size();
for (int i = 0; i < reportLinesSize; i++) {
if (reportLines.get(i).hasDifference) {
int depth = reportLines.get(i).depth;
for (int k = i - 1; k >= 0; k--) {
CompareReportLine prevNode = reportLines.get(k);
if (prevNode.depth < depth) {
if (prevNode.hasDifference) {
// Already set
break;
}
depth = prevNode.depth;
prevNode.hasDifference = true;
}
}
}
}
}
xml.startElement("html");
xml.startElement("head");
xml.startElement("meta");
xml.addAttribute("http-equiv", "Content-type");
xml.addAttribute("content", "text/html; charset=utf-8");
xml.endElement();
xml.startElement("title");
xml.addText("Compare report");
xml.endElement();
xml.endElement();
xml.startElement("body");
renderHeader();
xml.startElement("table");
xml.addAttribute("width", "100%");
//xml.addAttribute("border", "1");
xml.addAttribute("cellspacing", 0);
xml.addAttribute("cellpadding", 0);
renderBody(monitor);
xml.endElement();
xml.endElement();
xml.endElement();
this.xml.flush();
}
private void renderHeader() throws IOException
{
int maxLevel = 0;
for (CompareReportLine line : report.getReportLines()) {
if (line.depth > maxLevel) {
maxLevel = line.depth;
}
}
maxLevel++;
xml.startElement("style");
StringBuilder styles = new StringBuilder();
styles.append("table {font-family:\"Lucida Sans Unicode\", \"Lucida Grande\", Sans-Serif;font-size:12px;text-align:left;} ");
styles.append(".missing {color:red;} .differs {color:red;} ");
styles.append(".object td,th {border-top:solid 1px; border-right:solid 1px; border-color: black; white-space:nowrap;} ");
styles.append(".property td,th {border-top:dashed 1px; border-right:solid 1px; border-color: black; white-space:pre; } ");
styles.append(".struct {border-top:none; !important } ");
// styles.append(".object:first-child {border:none; } ");
// styles.append(".property:first-child {border:none; } ");
for (int i = 1; i <= maxLevel; i++) {
styles.append(".level").append(i).append(" td,th { text-align:left; padding-left:").append(20 * i).append("px; } ");
}
xml.addText(styles.toString(), false);
xml.endElement();
}
private void renderBody(DBRProgressMonitor monitor) throws IOException
{
// Table head
xml.startElement("tr");
xml.startElement("th");
xml.addText("Structure");
xml.endElement();
for (DBNDatabaseNode node : report.getNodes()) {
xml.startElement("th");
xml.addText(node.getNodeFullName());
xml.endElement();
}
xml.endElement();
// Table body
boolean showOnlyDifferences = settings.isShowOnlyDifferences();
int objectCount = report.getNodes().size();
List<CompareReportLine> reportLines = report.getReportLines();
int reportLinesSize = reportLines.size();
for (int i = 0; i < reportLinesSize; i++) {
monitor.worked(1);
CompareReportLine line = reportLines.get(i);
if (showOnlyDifferences && !line.hasDifference) {
continue;
}
boolean onlyStructure = line.structure instanceof DBNDatabaseFolder && !line.hasDifference;
// Skip empty folders
if (onlyStructure && (i >= reportLinesSize - 1 || reportLines.get(i + 1).depth <= line.depth)) {
continue;
}
xml.startElement("tr");
xml.addAttribute("class", "object level" + line.depth);
xml.addAttribute("valign", "top");
xml.startElement("td");
xml.addText(line.structure.getNodeType());
xml.endElement();
if (onlyStructure) {
xml.startElement("td");
xml.addAttribute("colspan", line.nodes.length);
xml.addText("&nbsp;", false);
xml.endElement();
} else {
for (int k = 0; k < objectCount; k++) {
xml.startElement("td");
if (line.nodes[k] == null) {
xml.addAttribute("class", "missing");
xml.addText("N/A");
} else {
xml.addText(line.nodes[k].getName());
}
xml.endElement();
}
}
xml.endElement();
if (line.properties != null) {
for (CompareReportProperty reportProperty : line.properties) {
boolean differs = false;
Object firstValue = null;
boolean hasValue = false;
for (int k = 0; k < reportProperty.values.length; k++) {
if (line.nodes[k] == null) {
// Ignore properties of missing objects
continue;
}
Object value = reportProperty.values[k];
if (value != null) {
hasValue = true;
if (firstValue == null) {
firstValue = value;
}
}
if (!CompareUtils.equalPropertyValues(value, firstValue)) {
differs = true;
break;
}
}
if (!hasValue) {
// Skip[ properties when nobody have it's value
continue;
}
if (showOnlyDifferences && !differs) {
continue;
}
xml.startElement("tr");
xml.addAttribute("class", "property level" + (line.depth + 1) + (differs ? " differs" : ""));
xml.addAttribute("valign", "top");
xml.startElement("td");
xml.addText(reportProperty.property.getDisplayName());
xml.endElement();
for (int k = 0; k < objectCount; k++) {
xml.startElement("td");
String stringValue = "";
if (reportProperty.values[k] != null) {
stringValue = reportProperty.values[k].toString();
}
if (CommonUtils.isEmpty(stringValue)) {
xml.addText("&nbsp;", false);
} else {
xml.addText(stringValue);
}
xml.endElement();
}
xml.endElement();
}
}
}
// Table footer
xml.startElement("tr");
xml.addAttribute("class", "object");
xml.startElement("td");
xml.addAttribute("colspan", report.getNodes().size() + 1);
xml.addText("" + reportLines.size() + " objects compared");
xml.endElement();
xml.endElement();
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 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.compare.simple;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseFolder;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.utils.GeneralUtils;
import org.jkiss.utils.CommonUtils;
import org.jkiss.utils.xml.XMLBuilder;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
public class CompareReportRenderer {
private CompareReport report;
private XMLBuilder xml;
private CompareObjectsSettings settings;
public void renderReport(DBRProgressMonitor monitor, CompareReport report, CompareObjectsSettings settings, OutputStream outputStream) throws IOException
{
this.report = report;
this.settings = settings;
this.xml = new XMLBuilder(outputStream, GeneralUtils.UTF8_ENCODING, true);
this.xml.setButify(true);
xml.addContent(
"<!DOCTYPE html \n" +
" PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n" +
" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
if (settings.isShowOnlyDifferences()) {
// Mark differences on tree nodes
List<CompareReportLine> reportLines = report.getReportLines();
int reportLinesSize = reportLines.size();
for (int i = 0; i < reportLinesSize; i++) {
if (reportLines.get(i).hasDifference) {
int depth = reportLines.get(i).depth;
for (int k = i - 1; k >= 0; k--) {
CompareReportLine prevNode = reportLines.get(k);
if (prevNode.depth < depth) {
if (prevNode.hasDifference) {
// Already set
break;
}
depth = prevNode.depth;
prevNode.hasDifference = true;
}
}
}
}
}
xml.startElement("html");
xml.startElement("head");
xml.startElement("meta");
xml.addAttribute("http-equiv", "Content-type");
xml.addAttribute("content", "text/html; charset=utf-8");
xml.endElement();
xml.startElement("title");
xml.addText("Compare report");
xml.endElement();
xml.endElement();
xml.startElement("body");
renderHeader();
xml.startElement("table");
xml.addAttribute("width", "100%");
//xml.addAttribute("border", "1");
xml.addAttribute("cellspacing", 0);
xml.addAttribute("cellpadding", 0);
renderBody(monitor);
xml.endElement();
xml.endElement();
xml.endElement();
this.xml.flush();
}
private void renderHeader() throws IOException
{
int maxLevel = 0;
for (CompareReportLine line : report.getReportLines()) {
if (line.depth > maxLevel) {
maxLevel = line.depth;
}
}
maxLevel++;
xml.startElement("style");
StringBuilder styles = new StringBuilder();
styles.append("table {font-family:\"Lucida Sans Unicode\", \"Lucida Grande\", Sans-Serif;font-size:12px;text-align:left;} ");
styles.append(".missing {color:red;} .differs {color:red;} ");
styles.append(".object td,th {border-top:solid 1px; border-right:solid 1px; border-color: black; white-space:nowrap;} ");
styles.append(".property td,th {border-top:dashed 1px; border-right:solid 1px; border-color: black; white-space:pre; } ");
styles.append(".struct {border-top:none; !important } ");
// styles.append(".object:first-child {border:none; } ");
// styles.append(".property:first-child {border:none; } ");
for (int i = 1; i <= maxLevel; i++) {
styles.append(".level").append(i).append(" td,th { text-align:left; padding-left:").append(20 * i).append("px; } ");
}
xml.addText(styles.toString(), false);
xml.endElement();
}
private void renderBody(DBRProgressMonitor monitor) throws IOException
{
// Table head
xml.startElement("tr");
xml.startElement("th");
xml.addText("Structure");
xml.endElement();
for (DBNDatabaseNode node : report.getNodes()) {
xml.startElement("th");
xml.addText(node.getNodeFullName());
xml.endElement();
}
xml.endElement();
// Table body
boolean showOnlyDifferences = settings.isShowOnlyDifferences();
int objectCount = report.getNodes().size();
List<CompareReportLine> reportLines = report.getReportLines();
int reportLinesSize = reportLines.size();
for (int i = 0; i < reportLinesSize; i++) {
monitor.worked(1);
CompareReportLine line = reportLines.get(i);
if (showOnlyDifferences && !line.hasDifference) {
continue;
}
boolean onlyStructure = line.structure instanceof DBNDatabaseFolder && !line.hasDifference;
// Skip empty folders
if (onlyStructure && (i >= reportLinesSize - 1 || reportLines.get(i + 1).depth <= line.depth)) {
continue;
}
xml.startElement("tr");
xml.addAttribute("class", "object level" + line.depth);
xml.addAttribute("valign", "top");
xml.startElement("td");
xml.addText(line.structure.getNodeType());
xml.endElement();
if (onlyStructure) {
xml.startElement("td");
xml.addAttribute("colspan", line.nodes.length);
xml.addText("&nbsp;", false);
xml.endElement();
} else {
for (int k = 0; k < objectCount; k++) {
xml.startElement("td");
if (line.nodes[k] == null) {
xml.addAttribute("class", "missing");
xml.addText("N/A");
} else {
xml.addText(line.nodes[k].getName());
}
xml.endElement();
}
}
xml.endElement();
if (line.properties != null) {
for (CompareReportProperty reportProperty : line.properties) {
boolean differs = false;
Object firstValue = null;
boolean hasValue = false;
for (int k = 0; k < reportProperty.values.length; k++) {
if (line.nodes[k] == null) {
// Ignore properties of missing objects
continue;
}
Object value = reportProperty.values[k];
if (value != null) {
hasValue = true;
if (firstValue == null) {
firstValue = value;
}
}
if (!CompareUtils.equalPropertyValues(value, firstValue)) {
differs = true;
break;
}
}
if (!hasValue) {
// Skip[ properties when nobody have it's value
continue;
}
if (showOnlyDifferences && !differs) {
continue;
}
xml.startElement("tr");
xml.addAttribute("class", "property level" + (line.depth + 1) + (differs ? " differs" : ""));
xml.addAttribute("valign", "top");
xml.startElement("td");
xml.addText(reportProperty.property.getDisplayName());
xml.endElement();
for (int k = 0; k < objectCount; k++) {
xml.startElement("td");
String stringValue = "";
if (reportProperty.values[k] != null) {
stringValue = reportProperty.values[k].toString();
}
if (CommonUtils.isEmpty(stringValue)) {
xml.addText("&nbsp;", false);
} else {
xml.addText(stringValue);
}
xml.endElement();
}
xml.endElement();
}
}
}
// Table footer
xml.startElement("tr");
xml.addAttribute("class", "object");
xml.startElement("td");
xml.addAttribute("colspan", report.getNodes().size() + 1);
xml.addText("" + reportLines.size() + " objects compared");
xml.endElement();
xml.endElement();
}
}
\ No newline at end of file
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 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.compare;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.utils.CommonUtils;
/**
* Compare utils
*/
public class CompareUtils {
public static boolean equalPropertyValues(Object value1, Object value2)
{
if (value1 instanceof DBSObject && value2 instanceof DBSObject) {
for (DBSObject curValue1 = (DBSObject) value1, curValue2 = (DBSObject) value2;
curValue1 != null && curValue2 != null;
curValue1 = curValue1.getParentObject(), curValue2 = curValue2.getParentObject())
{
if (curValue1.getClass() != curValue2.getClass()) {
return false;
}
if (curValue1 instanceof DBPDataSourceContainer) {
return true;
}
if (!CommonUtils.equalObjects(curValue1.getName(), curValue2.getName())) {
return false;
}
}
return true;
} else {
return CommonUtils.equalObjects(value1, value2);
}
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 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.compare.simple;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.utils.CommonUtils;
/**
* Compare utils
*/
public class CompareUtils {
public static boolean equalPropertyValues(Object value1, Object value2)
{
if (value1 instanceof DBSObject && value2 instanceof DBSObject) {
for (DBSObject curValue1 = (DBSObject) value1, curValue2 = (DBSObject) value2;
curValue1 != null && curValue2 != null;
curValue1 = curValue1.getParentObject(), curValue2 = curValue2.getParentObject())
{
if (curValue1.getClass() != curValue2.getClass()) {
return false;
}
if (curValue1 instanceof DBPDataSourceContainer) {
return true;
}
if (!CommonUtils.equalObjects(curValue1.getName(), curValue2.getName())) {
return false;
}
}
return true;
} else {
return CommonUtils.equalObjects(value1, value2);
}
}
}
......@@ -13,7 +13,6 @@ Export-Package: org.jkiss.dbeaver,
org.jkiss.dbeaver.registry,
org.jkiss.dbeaver.registry.tools,
org.jkiss.dbeaver.tools,
org.jkiss.dbeaver.tools.compare,
org.jkiss.dbeaver.tools.project,
org.jkiss.dbeaver.tools.scripts,
org.jkiss.dbeaver.ui.actions,
......@@ -68,5 +67,6 @@ Require-Bundle: org.eclipse.core.runtime,
org.jkiss.dbeaver.ui.editors.sql;visibility:=reexport,
org.jkiss.dbeaver.ui.navigator;visibility:=reexport,
org.jkiss.utils;visibility:=reexport,
org.jkiss.dbeaver.cmp.simple.ui,
org.jkiss.dbeaver.data.transfer
Bundle-Localization: OSGI-INF/l10n/bundle
......@@ -67,9 +67,6 @@ command.org.jkiss.dbeaver.core.transaction_mode.name=Transaction mode
command.org.jkiss.dbeaver.core.procedure.execute.name=Execute Stored Procedure
command.org.jkiss.dbeaver.core.procedure.execute.description=Open new SQL console with execute stored procedure query
command.org.jkiss.dbeaver.core.compare.objects.name=Compare
command.org.jkiss.dbeaver.core.compare.objects.description=Compare database objects
command.org.jkiss.dbeaver.core.edit.copy.adv_info=Copy Advanced Info
command.org.jkiss.dbeaver.core.edit.copy.special.label = Advanced copy
command.org.jkiss.dbeaver.core.edit.copy.special.name=Advanced Copy
......
......@@ -95,8 +95,6 @@ command.org.eclipse.ui.views.showView.queryManager = Ab
command.org.jkiss.dbeaver.core.commit.description = \u00C4nderungen in der aktuellen Sitzung \u00FCbernehmen
command.org.jkiss.dbeaver.core.commit.label = Commit
command.org.jkiss.dbeaver.core.commit.name = Commit
command.org.jkiss.dbeaver.core.compare.objects.description = Datenbankobjekte vergleichen
command.org.jkiss.dbeaver.core.compare.objects.name = Vergleichen
command.org.jkiss.dbeaver.core.connect.description = Verbindung mit der Datenbank herstellen
command.org.jkiss.dbeaver.core.connect.name = Verbinden
command.org.jkiss.dbeaver.core.disconnect.description = Verbindung mit der Datenbank trennen
......
......@@ -17,8 +17,6 @@ category.utility.name = Utilitaires
command.org.jkiss.dbeaver.core.commit.description = Appliquer les modifications de cette session (commit)
command.org.jkiss.dbeaver.core.commit.name = Appliquer (commit)
command.org.jkiss.dbeaver.core.commit.label = Appliquer (commit)
command.org.jkiss.dbeaver.core.compare.objects.description = Comparer des objets base de donn\u00E9es
command.org.jkiss.dbeaver.core.compare.objects.name = Comparer
command.org.jkiss.dbeaver.core.connect.description = Se connecter \u00E0 la base de donn\u00E9es
command.org.jkiss.dbeaver.core.connect.name = Se connecter
command.org.jkiss.dbeaver.core.disconnect.description = Se d\u00E9connecter de la base de donn\u00E9es
......
......@@ -64,9 +64,6 @@ command.org.jkiss.dbeaver.core.transaction_mode.name=\u30C8\u30E9\u30F3\u30B6\u3
command.org.jkiss.dbeaver.core.procedure.execute.name=\u30B9\u30C8\u30A2\u30C9\u30D7\u30ED\u30B7\u30FC\u30B8\u30E3\u3092\u5B9F\u884C\u3059\u308B
command.org.jkiss.dbeaver.core.procedure.execute.description=\u30B9\u30C8\u30A2\u30C9\u30D7\u30ED\u30B7\u30FC\u30B8\u30E3\u306E\u30AF\u30A8\u30EA\u3092\u5B9F\u884C\u3057\u3066\u65B0\u3057\u3044SQL\u30B3\u30F3\u30BD\u30FC\u30EB\u3092\u958B\u304F
command.org.jkiss.dbeaver.core.compare.objects.name=\u6BD4\u8F03
command.org.jkiss.dbeaver.core.compare.objects.description=\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u306E\u6BD4\u8F03
command.org.jkiss.dbeaver.core.edit.copy.adv_info=\u9AD8\u5EA6\u306A\u60C5\u5831\u3092\u30B3\u30D4\u30FC\u3059\u308B
command.org.jkiss.dbeaver.core.edit.copy.special.label =\u9AD8\u5EA6\u306A\u30B3\u30D4\u30FC
command.org.jkiss.dbeaver.core.edit.copy.special.name=\u30A2\u30C9\u30D0\u30F3\u30B9\u30C8\u30FB\u30B3\u30D4\u30FC
......
......@@ -62,9 +62,6 @@ command.org.jkiss.dbeaver.core.transaction_mode.name=\uD2B8\uB79C\uC7AD\uC158 \u
command.org.jkiss.dbeaver.core.procedure.execute.name=\uC800\uC7A5 \uD504\uB85C\uC2DC\uC800 \uC2E4\uD589
command.org.jkiss.dbeaver.core.procedure.execute.description=\uC800\uC7A5 \uD504\uB85C\uC2DC\uC800 \uC2E4\uD589 \uAC00\uB2A5\uD55C \uC0C8 SQL \uCF58\uC194 \uC5F4\uAE30
command.org.jkiss.dbeaver.core.compare.objects.name=\uBE44\uAD50
command.org.jkiss.dbeaver.core.compare.objects.description=\uB370\uC774\uD130\uBCA0\uC774\uC2A4 \uBE44\uAD50
#command.org.jkiss.dbeaver.core.edit.copy.adv_info=Copy Advanced Info
#command.org.jkiss.dbeaver.core.edit.copy.special.label = Advanced copy
#command.org.jkiss.dbeaver.core.edit.copy.special.name=Advanced Copy
......
......@@ -18,8 +18,6 @@ command.org.jkiss.dbeaver.core.txn.log.description = \u
command.org.jkiss.dbeaver.core.txn.log.name = \u0416\u0443\u0440\u043D\u0430\u043B \u0442\u0440\u0430\u043D\u0437\u0430\u043A\u0446\u0438\u0439
command.org.jkiss.dbeaver.core.txn.pending.description = \u0421\u043F\u0438\u0441\u043E\u043A \u043E\u0442\u043A\u0440\u044B\u0442\u044B\u0445 \u0442\u0440\u0430\u043D\u0437\u0430\u043A\u0446\u0438\u0439
command.org.jkiss.dbeaver.core.txn.pending.name = \u041E\u0442\u043A\u0440\u044B\u0442\u044B\u0435 \u0442\u0440\u0430\u043D\u0437\u0430\u043A\u0446\u0438\u0438
command.org.jkiss.dbeaver.core.compare.objects.description = \u0421\u0440\u0430\u0432\u043D\u0438\u0442\u044C \u043E\u0431\u044A\u0435\u043A\u0442\u044B \u0411\u0414
command.org.jkiss.dbeaver.core.compare.objects.name = \u0421\u0440\u0430\u0432\u043D\u0438\u0442\u044C
command.org.jkiss.dbeaver.core.connect.description = \u041F\u043E\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u044C\u0441\u044F \u043A \u0431\u0430\u0437\u0435 \u0434\u0430\u043D\u043D\u044B\u0445
command.org.jkiss.dbeaver.core.connect.name = \u041F\u043E\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u044C\u0441\u044F
command.org.jkiss.dbeaver.core.disconnect.description = \u041E\u0442\u0441\u043E\u0435\u0434\u0438\u043D\u0438\u0442\u044C\u0441\u044F \u043E\u0442 \u0431\u0430\u0437\u044B \u0434\u0430\u043D\u043D\u044B\u0445
......
......@@ -92,8 +92,6 @@ command.org.eclipse.ui.views.showView.queryManager = \u
command.org.jkiss.dbeaver.core.commit.description = \u63D0\u4EA4\u5F53\u524D\u4F1A\u8BDD\u4E2D\u7684\u6539\u52A8
command.org.jkiss.dbeaver.core.commit.label = \u63D0\u4EA4
command.org.jkiss.dbeaver.core.commit.name = \u63D0\u4EA4
command.org.jkiss.dbeaver.core.compare.objects.description = \u6BD4\u8F83\u6570\u636E\u5E93\u5BF9\u8C61
command.org.jkiss.dbeaver.core.compare.objects.name = \u6BD4\u8F83
command.org.jkiss.dbeaver.core.connect.description = \u8FDE\u63A5\u81F3\u6570\u636E\u5E93
command.org.jkiss.dbeaver.core.connect.name = \u8FDE\u63A5
command.org.jkiss.dbeaver.core.disconnect.description = \u65AD\u5F00\u6570\u636E\u5E93\u8FDE\u63A5
......
......@@ -130,8 +130,6 @@
<command id="org.jkiss.dbeaver.core.procedure.execute" name="%command.org.jkiss.dbeaver.core.procedure.execute.name" description="%command.org.jkiss.dbeaver.core.procedure.execute.description" categoryId="org.jkiss.dbeaver.core.database"/>
<command id="org.jkiss.dbeaver.core.compare.objects" name="%command.org.jkiss.dbeaver.core.compare.objects.name" description="%command.org.jkiss.dbeaver.core.compare.objects.description" categoryId="org.jkiss.dbeaver.core.util"/>
<command id="org.jkiss.dbeaver.core.edit.copy.special" name="%command.org.jkiss.dbeaver.core.edit.copy.special.name" description="%command.org.jkiss.dbeaver.core.edit.copy.special.description" categoryId="org.jkiss.dbeaver.core.util"/>
<command id="org.jkiss.dbeaver.core.edit.paste.special" name="%command.org.jkiss.dbeaver.core.edit.paste.special.name" description="%command.org.jkiss.dbeaver.core.edit.paste.special.description" categoryId="org.jkiss.dbeaver.core.util"/>
......@@ -148,7 +146,6 @@
</extension>
<extension point="org.eclipse.ui.commandImages">
<image commandId="org.jkiss.dbeaver.core.compare.objects" icon="platform:/plugin/org.jkiss.dbeaver.ui/icons/file/compare.png"/>
<image commandId="org.jkiss.dbeaver.core.driver.manager" icon="platform:/plugin/org.jkiss.dbeaver.ui/icons/driver_manager.png"/>
<image commandId="org.jkiss.dbeaver.core.new.connection" icon="platform:/plugin/org.jkiss.dbeaver.ui/icons/database_connect.png"/>
<image commandId="org.jkiss.dbeaver.core.navigator.bookmark.add" icon="platform:/plugin/org.jkiss.dbeaver.ui/icons/bookmark.png"/>
......@@ -260,17 +257,6 @@
</extension>
<extension point="org.eclipse.ui.handlers">
<handler commandId="org.jkiss.dbeaver.core.compare.objects" class="org.jkiss.dbeaver.tools.compare.CompareObjectsHandler">
<enabledWhen>
<with variable="selection">
<count value="(1-"/>
<iterate operator="and">
<adapt type="org.jkiss.dbeaver.model.navigator.DBNDatabaseNode"/>
</iterate>
</with>
</enabledWhen>
</handler>
<handler commandId="org.jkiss.dbeaver.core.driver.manager" class="org.jkiss.dbeaver.ui.actions.datasource.DriverManagerDialogHandler"/>
<handler commandId="org.jkiss.dbeaver.core.new.connection" class="org.jkiss.dbeaver.ui.actions.datasource.DataSourceCreateHandler">
<enabledWhen>
......@@ -824,13 +810,12 @@
<dynamic id="org.jkiss.dbeaver.core.menu.compare" class="org.jkiss.dbeaver.ui.editors.sql.generator.GenerateSQLContributor"/>
</menu>
-->
<separator name="export_import" visible="false"/>
<command commandId="org.jkiss.dbeaver.core.compare.objects">
<visibleWhen checkEnabled="true"/>
</command>
<separator name="export_import" visible="false"/>
<separator name="generate" visible="false"/>
<menu label="%menu.database.sql.generate" icon="platform:/plugin/org.jkiss.dbeaver.ui/icons/misc/sql.png">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册