diff --git a/plugins/org.jkiss.dbeaver.ext.oracle.ui/plugin.xml b/plugins/org.jkiss.dbeaver.ext.oracle.ui/plugin.xml index ce83214bd749766ce4d5d52d8cef9e329742b0a4..7d4736df0ad8ebf5c4a1a5e51f648d42e45e3057 100644 --- a/plugins/org.jkiss.dbeaver.ext.oracle.ui/plugin.xml +++ b/plugins/org.jkiss.dbeaver.ext.oracle.ui/plugin.xml @@ -307,6 +307,24 @@ singleton="false"> + + + + + + diff --git a/plugins/org.jkiss.dbeaver.ext.oracle.ui/src/org/jkiss/dbeaver/ext/oracle/ui/tools/maintenance/OracleToolTriggerDisable.java b/plugins/org.jkiss.dbeaver.ext.oracle.ui/src/org/jkiss/dbeaver/ext/oracle/ui/tools/maintenance/OracleToolTriggerDisable.java new file mode 100644 index 0000000000000000000000000000000000000000..550b231cfa54b0f1773feea50cdc549aa6dd76dc --- /dev/null +++ b/plugins/org.jkiss.dbeaver.ext.oracle.ui/src/org/jkiss/dbeaver/ext/oracle/ui/tools/maintenance/OracleToolTriggerDisable.java @@ -0,0 +1,24 @@ +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2021 DBeaver Corp and others + * + * 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.oracle.ui.tools.maintenance; + +public class OracleToolTriggerDisable extends OracleToolTriggerToggle { + + public OracleToolTriggerDisable() { + super(false); + } +} diff --git a/plugins/org.jkiss.dbeaver.ext.oracle.ui/src/org/jkiss/dbeaver/ext/oracle/ui/tools/maintenance/OracleToolTriggerEnable.java b/plugins/org.jkiss.dbeaver.ext.oracle.ui/src/org/jkiss/dbeaver/ext/oracle/ui/tools/maintenance/OracleToolTriggerEnable.java new file mode 100644 index 0000000000000000000000000000000000000000..fc5f821409660398f270744241c14e115756718d --- /dev/null +++ b/plugins/org.jkiss.dbeaver.ext.oracle.ui/src/org/jkiss/dbeaver/ext/oracle/ui/tools/maintenance/OracleToolTriggerEnable.java @@ -0,0 +1,24 @@ +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2021 DBeaver Corp and others + * + * 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.oracle.ui.tools.maintenance; + +public class OracleToolTriggerEnable extends OracleToolTriggerToggle { + + public OracleToolTriggerEnable() { + super(true); + } +} diff --git a/plugins/org.jkiss.dbeaver.ext.oracle.ui/src/org/jkiss/dbeaver/ext/oracle/ui/tools/maintenance/OracleToolTriggerToggle.java b/plugins/org.jkiss.dbeaver.ext.oracle.ui/src/org/jkiss/dbeaver/ext/oracle/ui/tools/maintenance/OracleToolTriggerToggle.java new file mode 100644 index 0000000000000000000000000000000000000000..eb275e36683445c67c142aff2d85d9cda687d4a3 --- /dev/null +++ b/plugins/org.jkiss.dbeaver.ext.oracle.ui/src/org/jkiss/dbeaver/ext/oracle/ui/tools/maintenance/OracleToolTriggerToggle.java @@ -0,0 +1,54 @@ +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2021 DBeaver Corp and others + * + * 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.oracle.ui.tools.maintenance; + +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.jkiss.dbeaver.model.struct.DBSObject; +import org.jkiss.dbeaver.tasks.ui.wizard.TaskConfigurationWizardDialog; +import org.jkiss.dbeaver.ui.navigator.NavigatorUtils; +import org.jkiss.dbeaver.ui.tools.IUserInterfaceTool; + +import java.util.Collection; + +public abstract class OracleToolTriggerToggle implements IUserInterfaceTool { + + private boolean isEnable; + + public OracleToolTriggerToggle(boolean isEnable) { + this.isEnable = isEnable; + } + + @Override + public void execute(IWorkbenchWindow window, IWorkbenchPart activePart, Collection objects) { + if (isEnable) { + TaskConfigurationWizardDialog.openNewTaskDialog( + window, + NavigatorUtils.getSelectedProject(), + "oracleToolTriggerEnable", + new StructuredSelection(objects.toArray())); + } else { + TaskConfigurationWizardDialog.openNewTaskDialog( + window, + NavigatorUtils.getSelectedProject(), + "oracleToolTriggerDisable", + new StructuredSelection(objects.toArray())); + } + } + +} diff --git a/plugins/org.jkiss.dbeaver.ext.oracle/plugin.xml b/plugins/org.jkiss.dbeaver.ext.oracle/plugin.xml index c81449d0d0c7d9da2b88876de6027a654e0b5abc..479254acd88c4078dfb8c78630c20e53442f1590 100644 --- a/plugins/org.jkiss.dbeaver.ext.oracle/plugin.xml +++ b/plugins/org.jkiss.dbeaver.ext.oracle/plugin.xml @@ -521,6 +521,14 @@ + + + + + + + + diff --git a/plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/tasks/OracleToolTableTriggerDisable.java b/plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/tasks/OracleToolTableTriggerDisable.java new file mode 100644 index 0000000000000000000000000000000000000000..dfbe771dcff6cb6e8abb98792106063816816feb --- /dev/null +++ b/plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/tasks/OracleToolTableTriggerDisable.java @@ -0,0 +1,47 @@ +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2021 DBeaver Corp and others + * + * 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.oracle.tasks; + +import org.jkiss.code.NotNull; +import org.jkiss.dbeaver.ext.oracle.model.OracleTableTrigger; +import org.jkiss.dbeaver.model.DBPEvaluationContext; +import org.jkiss.dbeaver.model.edit.DBEPersistAction; +import org.jkiss.dbeaver.model.exec.DBCException; +import org.jkiss.dbeaver.model.exec.DBCSession; +import org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction; +import org.jkiss.dbeaver.model.sql.task.SQLToolExecuteHandler; + +import java.util.List; + +public class OracleToolTableTriggerDisable extends SQLToolExecuteHandler { + + @NotNull + @Override + public OracleToolTableTriggerSettings createToolSettings() { + return new OracleToolTableTriggerSettings(); + } + + @Override + public void generateObjectQueries(DBCSession session, OracleToolTableTriggerSettings settings, List queries, OracleTableTrigger object) throws DBCException { + String sql = "ALTER TRIGGER " + object.getFullyQualifiedName(DBPEvaluationContext.DDL) + " DISABLE"; + queries.add(new SQLDatabasePersistAction(sql)); + } + + public boolean needsRefreshOnFinish() { + return true; + } +} diff --git a/plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/tasks/OracleToolTableTriggerEnable.java b/plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/tasks/OracleToolTableTriggerEnable.java new file mode 100644 index 0000000000000000000000000000000000000000..248ed3ff6f834b941df501c8da66c2699830d818 --- /dev/null +++ b/plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/tasks/OracleToolTableTriggerEnable.java @@ -0,0 +1,48 @@ +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2021 DBeaver Corp and others + * + * 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.oracle.tasks; + +import org.jkiss.code.NotNull; +import org.jkiss.dbeaver.ext.oracle.model.OracleTableTrigger; +import org.jkiss.dbeaver.model.DBPEvaluationContext; +import org.jkiss.dbeaver.model.edit.DBEPersistAction; +import org.jkiss.dbeaver.model.exec.DBCException; +import org.jkiss.dbeaver.model.exec.DBCSession; +import org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction; +import org.jkiss.dbeaver.model.sql.task.SQLToolExecuteHandler; + +import java.util.List; + +public class OracleToolTableTriggerEnable extends SQLToolExecuteHandler { + + @NotNull + @Override + public OracleToolTableTriggerSettings createToolSettings() { + return new OracleToolTableTriggerSettings(); + } + + @Override + public void generateObjectQueries(DBCSession session, OracleToolTableTriggerSettings settings, List queries, OracleTableTrigger object) throws DBCException { + String sql = "ALTER TRIGGER " + object.getFullyQualifiedName(DBPEvaluationContext.DDL) + " ENABLE"; + queries.add(new SQLDatabasePersistAction(sql)); + } + + public boolean needsRefreshOnFinish() { + return true; + } + +} diff --git a/plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/tasks/OracleToolTableTriggerSettings.java b/plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/tasks/OracleToolTableTriggerSettings.java new file mode 100644 index 0000000000000000000000000000000000000000..2e13e3dd0e268d66e159774fdd0d2cceba0795c3 --- /dev/null +++ b/plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/tasks/OracleToolTableTriggerSettings.java @@ -0,0 +1,24 @@ +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2021 DBeaver Corp and others + * + * 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.oracle.tasks; + +import org.jkiss.dbeaver.ext.oracle.model.OracleTableTrigger; +import org.jkiss.dbeaver.model.sql.task.SQLToolExecuteSettings; + +public class OracleToolTableTriggerSettings extends SQLToolExecuteSettings { + +}