diff --git a/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/edit/DBECommandListener.java b/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/edit/DBECommandListener.java index db6eec91d4bd1e5eec70b4256a2633f2335eae09..80bdbef836bcd8e6b191e1cf3d77bfb9350a9d39 100644 --- a/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/edit/DBECommandListener.java +++ b/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/edit/DBECommandListener.java @@ -22,14 +22,14 @@ package org.jkiss.dbeaver.model.edit; */ public interface DBECommandListener { - void onCommandChange(DBECommand command); + void onCommandChange(DBECommand command); void onSave(); void onReset(); - void onCommandDo(DBECommand command); + void onCommandDo(DBECommand command); - void onCommandUndo(DBECommand command); + void onCommandUndo(DBECommand command); } \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/edit/DBECommandAdapter.java b/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/edit/DBECommandAdapter.java index 380eb35349c27441906f0f3011ae962d02dba0b0..099f2e990cc542321810a949a19a9bce9a6a5afa 100644 --- a/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/edit/DBECommandAdapter.java +++ b/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/edit/DBECommandAdapter.java @@ -25,7 +25,7 @@ import org.jkiss.dbeaver.model.edit.DBECommandListener; public abstract class DBECommandAdapter implements DBECommandListener { @Override - public void onCommandChange(DBECommand command) + public void onCommandChange(DBECommand command) { } @@ -40,12 +40,12 @@ public abstract class DBECommandAdapter implements DBECommandListener { } @Override - public void onCommandDo(DBECommand command) + public void onCommandDo(DBECommand command) { } @Override - public void onCommandUndo(DBECommand command) + public void onCommandUndo(DBECommand command) { } } diff --git a/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVEntity.java b/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVEntity.java index bf19819ca5e0a6642810d6ec0357115f58afa494..0912bfc006dc1ad43c44d573c38eeb75144d1c26 100644 --- a/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVEntity.java +++ b/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVEntity.java @@ -501,9 +501,7 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec return result; } - public static String getDefaultDescriptionColumn(DBRProgressMonitor monitor, DBSEntityAttribute keyColumn) - throws DBException { - assert keyColumn.getParentObject() != null; + public static String getDefaultDescriptionColumn(DBRProgressMonitor monitor, DBSEntityAttribute keyColumn) throws DBException { Collection allColumns = keyColumn.getParentObject().getAttributes(monitor); if (allColumns == null || allColumns.isEmpty()) { @@ -572,12 +570,7 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec if (colorOverrides == null) { colorOverrides = new ArrayList<>(); } else { - for (Iterator iterator = colorOverrides.iterator(); iterator.hasNext(); ) { - DBVColorOverride c = iterator.next(); - if (c.matches(attrName, DBCLogicalOperator.EQUALS, co.getAttributeValues())) { - iterator.remove(); - } - } + colorOverrides.removeIf(c -> c.matches(attrName, DBCLogicalOperator.EQUALS, co.getAttributeValues())); } colorOverrides.add(co); } diff --git a/plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/editors/entity/EntityEditor.java b/plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/editors/entity/EntityEditor.java index 20e281404ca87aa64167b36606e854c8021f1d9e..7dca45d9ea5745b021529756bcfa8c18763eb7d8 100644 --- a/plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/editors/entity/EntityEditor.java +++ b/plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/editors/entity/EntityEditor.java @@ -480,10 +480,11 @@ public class EntityEditor extends MultiPageDatabaseEditor Map options = new HashMap<>(); options.put(DBPScriptObject.OPTION_OBJECT_SAVE, true); + DBPDataSource dataSource = getDatabaseObject().getDataSource(); try { DBEPersistAction[] persistActions = command.getPersistActions(monitor, options); script.append(SQLUtils.generateScript( - commandContext.getExecutionContext().getDataSource(), + dataSource, persistActions, false)); } catch (DBException e) { @@ -543,7 +544,7 @@ public class EntityEditor extends MultiPageDatabaseEditor // Command listener commandListener = new DBECommandAdapter() { @Override - public void onCommandChange(DBECommand command) + public void onCommandChange(DBECommand command) { UIUtils.syncExec(() -> firePropertyChange(IEditorPart.PROP_DIRTY)); } @@ -828,12 +829,11 @@ public class EntityEditor extends MultiPageDatabaseEditor } } - private void addActionsContributor(IEditorPart editor, Class contributorClass) throws InstantiationException, IllegalAccessException - { + private void addActionsContributor(IEditorPart editor, Class contributorClass) throws Exception { GlobalContributorManager contributorManager = GlobalContributorManager.getInstance(); IEditorActionBarContributor contributor = contributorManager.getContributor(contributorClass); if (contributor == null) { - contributor = contributorClass.newInstance(); + contributor = contributorClass.getDeclaredConstructor().newInstance(); } contributorManager.addContributor(contributor, editor); actionContributors.put(editor, contributor); diff --git a/plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/editors/entity/properties/TabbedFolderPageForm.java b/plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/editors/entity/properties/TabbedFolderPageForm.java index c24233f0ed66e431ee87a3b46074a20c92631ecf..08f438b04df4e7b6e0b00e6c15653a672e5ecb41 100644 --- a/plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/editors/entity/properties/TabbedFolderPageForm.java +++ b/plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/editors/entity/properties/TabbedFolderPageForm.java @@ -40,6 +40,7 @@ import org.jkiss.dbeaver.model.DBUtils; import org.jkiss.dbeaver.model.DBValueFormatting; import org.jkiss.dbeaver.model.data.DBDDisplayFormat; import org.jkiss.dbeaver.model.edit.DBECommand; +import org.jkiss.dbeaver.model.edit.DBECommandContext; import org.jkiss.dbeaver.model.edit.DBEObjectRenamer; import org.jkiss.dbeaver.model.edit.prop.DBECommandProperty; import org.jkiss.dbeaver.model.impl.edit.DBECommandAdapter; @@ -61,7 +62,6 @@ import org.jkiss.dbeaver.utils.GeneralUtils; import org.jkiss.utils.BeanUtils; import org.jkiss.utils.CommonUtils; -import java.lang.reflect.InvocationTargetException; import java.util.List; import java.util.*; @@ -109,34 +109,37 @@ public class TabbedFolderPageForm extends TabbedFolderPage implements IRefreshab curPropertySource = input.getPropertySource(); - input.getCommandContext().addCommandListener(new DBECommandAdapter() { - @Override - public void onCommandChange(DBECommand command) { - UIUtils.asyncExec(() -> { - updateEditButtonsState(); - if (command instanceof DBECommandProperty) { - // We need to exclude current prop from update - // Simple value compare on update is not enough because value can be transformed (e.g. uppercased) - // and it will differ from the value in edit control - Object propId = ((DBECommandProperty) command).getHandler().getId(); - updateOtherPropertyValues(propId); - } - }); - } + DBECommandContext commandContext = input.getCommandContext(); + if (commandContext != null) { + commandContext.addCommandListener(new DBECommandAdapter() { + @Override + public void onCommandChange(DBECommand command) { + UIUtils.asyncExec(() -> { + updateEditButtonsState(); + if (command instanceof DBECommandProperty) { + // We need to exclude current prop from update + // Simple value compare on update is not enough because value can be transformed (e.g. uppercased) + // and it will differ from the value in edit control + Object propId = ((DBECommandProperty) command).getHandler().getId(); + updateOtherPropertyValues(propId); + } + }); + } - @Override - public void onSave() { - UIUtils.asyncExec(() -> updateEditButtonsState()); - } + @Override + public void onSave() { + UIUtils.asyncExec(() -> updateEditButtonsState()); + } - @Override - public void onReset() { - UIUtils.asyncExec(() -> { - refreshProperties(); - updateEditButtonsState(); - }); - } - }); + @Override + public void onReset() { + UIUtils.asyncExec(() -> { + refreshProperties(); + updateEditButtonsState(); + }); + } + }); + } propertiesGroup.addDisposeListener(e -> dispose()); @@ -147,7 +150,8 @@ public class TabbedFolderPageForm extends TabbedFolderPage implements IRefreshab if (saveButton == null || saveButton.isDisposed()) { return; } - boolean isDirty = input.getCommandContext().isDirty(); + DBECommandContext commandContext = input.getCommandContext(); + boolean isDirty = commandContext != null && commandContext.isDirty(); saveButton.setEnabled(isDirty); revertButton.setEnabled(isDirty); scriptButton.setEnabled(isDirty); @@ -352,7 +356,7 @@ public class TabbedFolderPageForm extends TabbedFolderPage implements IRefreshab LoadingJob.createService( new DatabaseLoadService>("Load main properties", databaseObject.getDataSource()) { @Override - public Map evaluate(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + public Map evaluate(DBRProgressMonitor monitor) { DBPPropertySource propertySource = TabbedFolderPageForm.this.curPropertySource; monitor.beginTask("Load '" + DBValueFormatting.getDefaultValueDisplayString(propertySource.getEditableValue(), DBDDisplayFormat.UI) + "' properties", allProps.size()); Map propValues = new HashMap<>(); @@ -666,7 +670,7 @@ public class TabbedFolderPageForm extends TabbedFolderPage implements IRefreshab final Object[] enumConstants = propertyType.getEnumConstants(); final String[] strings = new String[enumConstants.length]; for (int i = 0, itemsLength = enumConstants.length; i < itemsLength; i++) { - strings[i] = ((Enum) enumConstants[i]).name(); + strings[i] = ((Enum) enumConstants[i]).name(); } combo.setItems(strings); } @@ -692,7 +696,7 @@ public class TabbedFolderPageForm extends TabbedFolderPage implements IRefreshab if (value instanceof DBPNamedObject) { return ((DBPNamedObject) value).getName(); } else if (value instanceof Enum) { - return ((Enum) value).name(); + return ((Enum) value).name(); } else { return DBValueFormatting.getDefaultValueDisplayString(value, DBDDisplayFormat.EDIT); } diff --git a/plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/controls/finder/AdvancedList.java b/plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/controls/finder/AdvancedList.java index 1e154d3ed347168adee62b7f9867ff34a5d25311..e9669c7a6b16bbacb463d21dc29c9d6decb2859a 100644 --- a/plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/controls/finder/AdvancedList.java +++ b/plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/controls/finder/AdvancedList.java @@ -18,7 +18,10 @@ package org.jkiss.dbeaver.ui.controls.finder; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; -import org.eclipse.swt.events.*; +import org.eclipse.swt.events.FocusAdapter; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Point; @@ -26,7 +29,10 @@ import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.RowLayout; -import org.eclipse.swt.widgets.*; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.TypedListener; import org.jkiss.dbeaver.Log; import org.jkiss.dbeaver.ui.UIStyles; import org.jkiss.dbeaver.ui.UIUtils; @@ -66,7 +72,28 @@ public class AdvancedList extends ScrolledComposite { setLayoutData(new GridData(GridData.FILL_BOTH)); } - this.container = new Canvas(this, SWT.NONE); + this.container = new Canvas(this, SWT.NONE) { + @Override + public Point computeSize(int wHint, int hHint) { + return computeSize(wHint, hHint, true); + } + + @Override + public Point computeSize(int wHint, int hHint, boolean changed) { + if (wHint == SWT.DEFAULT && hHint == SWT.DEFAULT) { + return new Point(100, 100); + } + return super.computeSize(wHint, hHint, changed); +/* + // Do not calc real size because RowLayout will fill to maximum screen width + if (wHint == SWT.DEFAULT && hHint == SWT.DEFAULT) { + //return getParent().getSize(); + return super.computeSize(wHint, hHint, changed); + } + return new Point(wHint, hHint); +*/ + } + }; this.setContent(this.container); this.setExpandHorizontal( true ); @@ -178,27 +205,6 @@ public class AdvancedList extends ScrolledComposite { return textSize; } - @Override - public Point computeSize(int wHint, int hHint) { - return computeSize(wHint, hHint, false); - } - - @Override - public Point computeSize(int wHint, int hHint, boolean changed) { - if (wHint == SWT.DEFAULT && hHint == SWT.DEFAULT) { - return new Point(100, 100); - } - return super.computeSize(wHint, hHint, changed); -/* - // Do not calc real size because RowLayout will fill to maximum screen width - if (wHint == SWT.DEFAULT && hHint == SWT.DEFAULT) { - //return getParent().getSize(); - return super.computeSize(wHint, hHint, changed); - } - return new Point(wHint, hHint); -*/ - } - public Canvas getContainer() { return container; } diff --git a/plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/controls/finder/AdvancedListItem.java b/plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/controls/finder/AdvancedListItem.java index 2107c4b633d6d6d01793af317e31264a168cfce5..4db3e0d87d08767a0fa9f0ec367fba701e85f375 100644 --- a/plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/controls/finder/AdvancedListItem.java +++ b/plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/controls/finder/AdvancedListItem.java @@ -40,7 +40,7 @@ public class AdvancedListItem extends Canvas { final TextLayout textLayout; public AdvancedListItem(AdvancedList list, Object item, ILabelProvider labelProvider) { - super(list.getContainer(), SWT.DOUBLE_BUFFERED); + super(list.getContainer(), SWT.NONE); this.labelProvider = labelProvider; this.list = list; this.list.addItem(this); diff --git a/plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/controls/finder/viewer/AdvancedListViewer.java b/plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/controls/finder/viewer/AdvancedListViewer.java index 17adc68124b6e75ff0e6934b2de83109ab68c3b2..11a8fe418cd03f555b64dfe4cb6e39eddb7ecb2e 100644 --- a/plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/controls/finder/viewer/AdvancedListViewer.java +++ b/plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/controls/finder/viewer/AdvancedListViewer.java @@ -97,14 +97,13 @@ public class AdvancedListViewer extends StructuredViewer { IStructuredContentProvider contentProvider = (IStructuredContentProvider) getContentProvider(); ILabelProvider labelProvider = (ILabelProvider) getLabelProvider(); - IToolTipProvider toolTipProvider = labelProvider instanceof IToolTipProvider ? (IToolTipProvider) labelProvider : null; + //IToolTipProvider toolTipProvider = labelProvider instanceof IToolTipProvider ? (IToolTipProvider) labelProvider : null; Object[] elements = contentProvider.getElements(element); for (ViewerFilter filter : getFilters()) { elements = filter.filter(this, (Object)null, elements); } for (Object item : elements) { - AdvancedListItem listItem = new AdvancedListItem(control, item, labelProvider); - listItem.setData(item); + new AdvancedListItem(control, item, labelProvider); } if (true) { diff --git a/plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/controls/folders/TabbedFolderList.java b/plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/controls/folders/TabbedFolderList.java index 1e5b6948846a3cf5859095c79796144ecd9ca816..de2c545f4eee340d9bedfb03190340ef65685054 100644 --- a/plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/controls/folders/TabbedFolderList.java +++ b/plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/controls/folders/TabbedFolderList.java @@ -1,4 +1,4 @@ -/******************************************************************************* +/* * Copyright (c) 2001, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -783,9 +783,7 @@ public class TabbedFolderList extends Composite { * that the navigation elements fit. */ int ret = getBounds().height - 20; - return (ret > tabHeight) ? tabHeight - : (ret < 5) ? 5 - : ret; + return (ret > tabHeight) ? tabHeight : Math.max(ret, 5); } return tabHeight; }