提交 e3c5b157 编写于 作者: J jurgen

Code cleanup

上级 3f9912b7
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package org.jkiss.dbeaver.model.project;
import org.jkiss.dbeaver.model.DBPNamedObject;
/**
* Project
*/
public interface DBPProject extends DBPNamedObject {
}
......@@ -31,20 +31,12 @@ import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.program.Program;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.core.DBeaverUI;
import org.jkiss.dbeaver.core.Log;
import org.jkiss.dbeaver.model.runtime.DBRProcessDescriptor;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress;
import org.jkiss.dbeaver.model.runtime.DBRShellCommand;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.views.process.ShellProcessView;
import org.jkiss.utils.ArrayUtils;
import org.jkiss.utils.CommonUtils;
......@@ -401,43 +393,6 @@ public class RuntimeUtils {
return false;
}
public static DBRProcessDescriptor processCommand(
final DBRShellCommand command,
final Map<String, Object> variables)
{
final Shell shell = DBeaverUI.getActiveWorkbenchShell();
final DBRProcessDescriptor processDescriptor = new DBRProcessDescriptor(command, variables);
// Direct execute
try {
processDescriptor.execute();
} catch (DBException e) {
UIUtils.showErrorDialog(shell, "Execute process", processDescriptor.getName(), e);
}
if (command.isShowProcessPanel()) {
shell.getDisplay().asyncExec(new Runnable() {
@Override
public void run()
{
try {
final ShellProcessView processView =
(ShellProcessView) DBeaverUI.getActiveWorkbenchWindow().getActivePage().showView(
ShellProcessView.VIEW_ID,
ShellProcessView.getNextId(),
IWorkbenchPage.VIEW_VISIBLE
);
processView.initProcess(processDescriptor);
} catch (PartInitException e) {
log.error(e);
}
}
});
}
if (command.isWaitProcessFinish()) {
processDescriptor.waitFor();
}
return processDescriptor;
}
public static String getNativeBinaryName(String binName)
{
return DBeaverCore.getInstance().getLocalSystem().isWindows() ? binName + ".exe" : binName;
......@@ -528,7 +483,7 @@ public class RuntimeUtils {
if (program != null) {
final ImageData imageData = program.getImageData();
if (imageData != null) {
programInfo.image = new Image(DBeaverUI.getDisplay(), imageData);
programInfo.image = new Image(null, imageData);
}
}
programMap.put(fileExtension, programInfo);
......
......@@ -18,13 +18,20 @@
package org.jkiss.dbeaver.runtime.jobs;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.core.DBeaverUI;
import org.jkiss.dbeaver.core.Log;
import org.jkiss.dbeaver.model.DBPConnectionEventType;
import org.jkiss.dbeaver.model.DBPConnectionInfo;
import org.jkiss.dbeaver.model.runtime.DBRProcessDescriptor;
import org.jkiss.dbeaver.model.runtime.DBRShellCommand;
import org.jkiss.dbeaver.registry.DataSourceDescriptor;
import org.jkiss.dbeaver.runtime.AbstractJob;
import org.jkiss.dbeaver.runtime.RuntimeUtils;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.views.process.ShellProcessView;
import org.jkiss.utils.CommonUtils;
import java.util.HashMap;
......@@ -35,6 +42,8 @@ import java.util.Map;
*/
public abstract class EventProcessorJob extends AbstractJob {
static final Log log = Log.getLog(EventProcessorJob.class);
public static final String VARIABLE_HOST = "host";
public static final String VARIABLE_PORT = "port";
public static final String VARIABLE_SERVER = "server";
......@@ -68,11 +77,46 @@ public abstract class EventProcessorJob extends AbstractJob {
variables.put(VARIABLE_PASSWORD, info.getUserPassword());
variables.put(VARIABLE_URL, info.getUrl());
DBRProcessDescriptor process = RuntimeUtils.processCommand(command, variables);
DBRProcessDescriptor process = processCommand(command, variables);
if (process != null) {
container.addChildProcess(process);
}
}
}
private DBRProcessDescriptor processCommand(DBRShellCommand command, Map<String, Object> variables) {
final Shell shell = DBeaverUI.getActiveWorkbenchShell();
final DBRProcessDescriptor processDescriptor = new DBRProcessDescriptor(command, variables);
// Direct execute
try {
processDescriptor.execute();
} catch (DBException e) {
UIUtils.showErrorDialog(shell, "Execute process", processDescriptor.getName(), e);
}
if (command.isShowProcessPanel()) {
shell.getDisplay().asyncExec(new Runnable() {
@Override
public void run()
{
try {
final ShellProcessView processView =
(ShellProcessView) DBeaverUI.getActiveWorkbenchWindow().getActivePage().showView(
ShellProcessView.VIEW_ID,
ShellProcessView.getNextId(),
IWorkbenchPage.VIEW_VISIBLE
);
processView.initProcess(processDescriptor);
} catch (PartInitException e) {
log.error(e);
}
}
});
}
if (command.isWaitProcessFinish()) {
processDescriptor.waitFor();
}
return processDescriptor;
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package org.jkiss.dbeaver.tools.transfer.stream;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.data.DBDDisplayFormat;
import org.jkiss.dbeaver.tools.transfer.IDataTransferProcessor;
import java.util.List;
/**
* Stream exporter descriptor
*/
public interface IStreamDataExporterDescriptor extends IDataTransferProcessor {
DBDDisplayFormat getExportFormat();
String getFileExtension();
List<IPropertyDescriptor> getProperties();
IStreamDataExporter createExporter() throws DBException;
}
......@@ -186,29 +186,6 @@ public class StreamConsumerSettings implements IDataTransferSettings {
if (!CommonUtils.isEmpty(dialogSettings.get("formatterProfile"))) {
formatterProfile = DataFormatterRegistry.getInstance().getCustomProfile(dialogSettings.get("formatterProfile"));
}
/*
IDialogSettings[] expSections = dialogSettings.getSections();
if (expSections != null && expSections.length > 0) {
for (IDialogSettings expSection : expSections) {
expId = expSection.getName();
IStreamDataExporterDescriptor exporter = DBeaverCore.getInstance().getDataTransferRegistry().getDataExporter(expId);
if (exporter != null) {
Map<Object, Object> expProps = new HashMap<Object, Object>();
exporterPropsHistory.put(exporter, expProps);
for (IPropertyDescriptor prop : exporter.getProperties()) {
Object value = expSection.get(prop.getId().toString());
if (value != null) {
if ("extractImages".equals(prop.getId())) {
value = Boolean.parseBoolean((String) value);
}
expProps.put(prop.getId(), value);
}
}
}
}
}
setExporterDescriptor(dataExporter);
*/
}
@Override
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册