Search in sources :

Example 16 with DBRShellCommand

use of org.jkiss.dbeaver.model.runtime.DBRShellCommand in project dbeaver by dbeaver.

the class EditShellCommandsDialogPage method selectEventType.

private void selectEventType(DBPConnectionEventType eventType) {
    DBRShellCommand command = eventType == null ? null : eventsCache.get(eventType);
    commandText.setEnabled(command != null && command.isEnabled());
    showProcessCheck.setEnabled(command != null && command.isEnabled());
    waitFinishCheck.setEnabled(command != null && command.isEnabled());
    waitFinishTimeoutMs.setEnabled(waitFinishCheck.isEnabled());
    terminateCheck.setEnabled(command != null && command.isEnabled());
    pauseAfterExecute.setEnabled(command != null && command.isEnabled());
    workingDirectory.setEnabled(command != null && command.isEnabled());
    workingDirectory.getTextControl().setEnabled(command != null && command.isEnabled());
    if (command != null) {
        commandText.setText(CommonUtils.toString(command.getCommand()));
        showProcessCheck.setSelection(command.isShowProcessPanel());
        waitFinishCheck.setSelection(command.isWaitProcessFinish());
        waitFinishTimeoutMs.setSelection(command.getWaitProcessTimeoutMs());
        terminateCheck.setSelection(command.isTerminateAtDisconnect());
        pauseAfterExecute.setSelection(command.getPauseAfterExecute());
        workingDirectory.setText(CommonUtils.notEmpty(command.getWorkingDirectory()));
    } else {
        // $NON-NLS-1$
        commandText.setText("");
        showProcessCheck.setSelection(false);
        waitFinishCheck.setSelection(false);
        waitFinishTimeoutMs.setSelection(DBRShellCommand.WAIT_PROCESS_TIMEOUT_FOREVER);
        terminateCheck.setSelection(false);
        pauseAfterExecute.setSelection(0);
        workingDirectory.setText("");
    }
}
Also used : DBRShellCommand(org.jkiss.dbeaver.model.runtime.DBRShellCommand)

Example 17 with DBRShellCommand

use of org.jkiss.dbeaver.model.runtime.DBRShellCommand in project dbeaver by dbeaver.

the class EditShellCommandsDialogPage method getActiveCommand.

private DBRShellCommand getActiveCommand() {
    DBPConnectionEventType eventType = getSelectedEventType();
    if (eventType != null) {
        DBRShellCommand command = eventsCache.get(eventType);
        if (command == null) {
            // $NON-NLS-1$
            command = new DBRShellCommand("");
            eventsCache.put(eventType, command);
        }
        return command;
    }
    return null;
}
Also used : DBPConnectionEventType(org.jkiss.dbeaver.model.connection.DBPConnectionEventType) DBRShellCommand(org.jkiss.dbeaver.model.runtime.DBRShellCommand)

Example 18 with DBRShellCommand

use of org.jkiss.dbeaver.model.runtime.DBRShellCommand in project dbeaver by dbeaver.

the class ConnectionPageShellCommands method selectEventType.

private void selectEventType(DBPConnectionEventType eventType) {
    DBRShellCommand command = eventType == null ? null : eventsCache.get(eventType);
    commandText.setEnabled(command != null && command.isEnabled());
    showProcessCheck.setEnabled(command != null && command.isEnabled());
    waitFinishCheck.setEnabled(command != null && command.isEnabled());
    waitFinishTimeoutMs.setEnabled(waitFinishCheck.isEnabled());
    terminateCheck.setEnabled(command != null && command.isEnabled());
    pauseAfterExecute.setEnabled(command != null && command.isEnabled());
    workingDirectory.setEnabled(command != null && command.isEnabled());
    workingDirectory.getTextControl().setEnabled(command != null && command.isEnabled());
    if (command != null) {
        commandText.setText(CommonUtils.toString(command.getCommand()));
        showProcessCheck.setSelection(command.isShowProcessPanel());
        waitFinishCheck.setSelection(command.isWaitProcessFinish());
        waitFinishTimeoutMs.setSelection(command.getWaitProcessTimeoutMs());
        terminateCheck.setSelection(command.isTerminateAtDisconnect());
        pauseAfterExecute.setSelection(command.getPauseAfterExecute());
        workingDirectory.setText(CommonUtils.notEmpty(command.getWorkingDirectory()));
    } else {
        // $NON-NLS-1$
        commandText.setText("");
        showProcessCheck.setSelection(false);
        waitFinishCheck.setSelection(false);
        waitFinishTimeoutMs.setSelection(DBRShellCommand.WAIT_PROCESS_TIMEOUT_FOREVER);
        terminateCheck.setSelection(false);
        pauseAfterExecute.setSelection(0);
        workingDirectory.setText("");
    }
}
Also used : DBRShellCommand(org.jkiss.dbeaver.model.runtime.DBRShellCommand)

Example 19 with DBRShellCommand

use of org.jkiss.dbeaver.model.runtime.DBRShellCommand in project dbeaver by dbeaver.

the class ConnectionPageShellCommands method updateEvent.

private void updateEvent(boolean commandChange) {
    DBPConnectionEventType eventType = getSelectedEventType();
    DBRShellCommand command = getActiveCommand();
    if (command != null) {
        boolean prevEnabled = command.isEnabled();
        if (commandChange) {
            command.setCommand(commandText.getText());
        } else {
            TableItem item = getEventItem(eventType);
            if (item != null) {
                command.setEnabled(item.getChecked());
            }
            command.setShowProcessPanel(showProcessCheck.getSelection());
            command.setWaitProcessFinish(waitFinishCheck.getSelection());
            waitFinishTimeoutMs.setEnabled(waitFinishCheck.getSelection());
            command.setWaitProcessTimeoutMs(waitFinishTimeoutMs.getSelection());
            command.setTerminateAtDisconnect(terminateCheck.getSelection());
            command.setPauseAfterExecute(pauseAfterExecute.getSelection());
            command.setWorkingDirectory(workingDirectory.getText());
            if (prevEnabled != command.isEnabled()) {
                selectEventType(eventType);
            }
        }
    } else if (!commandChange) {
        selectEventType(null);
    }
}
Also used : DBPConnectionEventType(org.jkiss.dbeaver.model.connection.DBPConnectionEventType) DBRShellCommand(org.jkiss.dbeaver.model.runtime.DBRShellCommand)

Example 20 with DBRShellCommand

use of org.jkiss.dbeaver.model.runtime.DBRShellCommand in project dbeaver by dbeaver.

the class StreamTransferConsumer method executeFinishCommand.

private void executeFinishCommand() {
    String commandLine = translatePattern(settings.getFinishProcessCommand(), outputFile);
    DBRShellCommand command = new DBRShellCommand(commandLine);
    DBRProcessDescriptor processDescriptor = new DBRProcessDescriptor(command);
    try {
        processDescriptor.execute();
    } catch (DBException e) {
        DBWorkbench.getPlatformUI().showError(DTMessages.stream_transfer_consumer_title_run_process, NLS.bind(DTMessages.stream_transfer_consumer_message_error_running_process, commandLine), e);
    }
}
Also used : DBException(org.jkiss.dbeaver.DBException) DBRProcessDescriptor(org.jkiss.dbeaver.model.runtime.DBRProcessDescriptor) DBRShellCommand(org.jkiss.dbeaver.model.runtime.DBRShellCommand)

Aggregations

DBRShellCommand (org.jkiss.dbeaver.model.runtime.DBRShellCommand)25 DBPConnectionEventType (org.jkiss.dbeaver.model.connection.DBPConnectionEventType)13 DBException (org.jkiss.dbeaver.DBException)6 DBWHandlerConfiguration (org.jkiss.dbeaver.model.net.DBWHandlerConfiguration)6 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 GridData (org.eclipse.swt.layout.GridData)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 DBPDataSourceOrigin (org.jkiss.dbeaver.model.DBPDataSourceOrigin)4 SimplePreferenceStore (org.jkiss.dbeaver.model.impl.preferences.SimplePreferenceStore)4 DBRProcessDescriptor (org.jkiss.dbeaver.model.runtime.DBRProcessDescriptor)4 TextWithOpenFolder (org.jkiss.dbeaver.ui.controls.TextWithOpenFolder)3 VariablesHintLabel (org.jkiss.dbeaver.ui.controls.VariablesHintLabel)3 TypeToken (com.google.gson.reflect.TypeToken)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 SWT (org.eclipse.swt.SWT)2 ModifyEvent (org.eclipse.swt.events.ModifyEvent)2 ModifyListener (org.eclipse.swt.events.ModifyListener)2