Commit 32be3aca authored by igoshin's avatar igoshin
Browse files

#14360 add support to remove a JDBC query

parent 46c59039
......@@ -55,18 +55,7 @@ import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.swt.widgets.*;
import org.eclipse.wb.swt.SWTResourceManager;
import org.genesys2.anno.model.ColumnDef;
import org.genesys2.anno.model.Settings;
......@@ -419,6 +408,14 @@ public class AppWindow {
builder.removeDataSource((IDataSource) selectedObject);
tableViewer.refresh();
}
if (selectedObject instanceof JdbcDataSourceSheet) {
IStructuredSelection thisSelection = (IStructuredSelection) treeViewer.getSelection();
IDataSource currentSource= (IDataSource) ((TreeSelection) thisSelection).getPaths()[0].getFirstSegment();
if (confirmRemoveQuery()){
currentSource.removeSheet((IDataSourceSheet) selectedObject);
}
tableViewer.refresh();
}
}
treeViewer.refresh();
......@@ -434,8 +431,12 @@ public class AppWindow {
Object selectedObject = iterator.next();
_log.debug("Sel " + selectedObject);
if (selectedObject instanceof IDataSource)
enabled = true;
if (selectedObject instanceof IDataSource) {
enabled = true;
}
if(selectedObject instanceof JdbcDataSourceSheet){
enabled=true;
}
}
mntmRemoveFile.setEnabled(enabled);
......@@ -639,7 +640,14 @@ public class AppWindow {
return tbtmOther;
}
private void doSaveWorkSpace() {
private boolean confirmRemoveQuery() {
MessageBox dialog = new MessageBox(shlGenesysMagic, SWT.ICON_WARNING | SWT.OK | SWT.CANCEL);
dialog.setText("Remove query");
dialog.setMessage("Do you want remove this query?");
return dialog.open() == SWT.OK;
}
private void doSaveWorkSpace() {
FileDialog dialog = new FileDialog(shlGenesysMagic, SWT.SAVE);
dialog.setFilterNames(new String[] { "JSON Format" });
dialog.setFilterExtensions(new String[] { "*.json" });
......
......@@ -51,6 +51,11 @@ public class DataSourceFile extends AbstractModelObject implements IDataSource {
firePropertyChange("sheets", null, sheets);
}
@Override
public void removeSheet(IDataSourceSheet sourceSheet){
this.sheets.remove(sourceSheet);
}
@Override
public String toString() {
return file.getName();
......
......@@ -14,4 +14,6 @@ public interface IDataSource {
public List<IDataSourceSheet> getSheets();
void setSheets(List<IDataSourceSheet> sheets);
void removeSheet(IDataSourceSheet sourceSheet);
}
......@@ -44,7 +44,13 @@ public class JdbcDataSource extends AbstractModelObject implements IDataSource {
firePropertyChange("sheets", null, sheets);
}
public void addSheet(JdbcDataSourceSheet sourceSheet) {
@Override
public void removeSheet(IDataSourceSheet sourceSheet) {
this.dataSourceSheets.remove(sourceSheet);
firePropertyChange("sheets", null, null);
}
public void addSheet(JdbcDataSourceSheet sourceSheet) {
dataSourceSheets.add(sourceSheet);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment