提交 f87ad545 编写于 作者: S Serge Rider

Code styling


Former-commit-id: 6375bab2
上级 f953d376
......@@ -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
......@@ -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)
{
}
}
......@@ -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<? extends DBSEntityAttribute> 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<DBVColorOverride> 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);
}
......
......@@ -480,10 +480,11 @@ public class EntityEditor extends MultiPageDatabaseEditor
Map<String, Object> 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<? extends IEditorActionBarContributor> contributorClass) throws InstantiationException, IllegalAccessException
{
private void addActionsContributor(IEditorPart editor, Class<? extends IEditorActionBarContributor> 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);
......
......@@ -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<Map<DBPPropertyDescriptor, Object>>("Load main properties", databaseObject.getDataSource()) {
@Override
public Map<DBPPropertyDescriptor, Object> evaluate(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
public Map<DBPPropertyDescriptor, Object> evaluate(DBRProgressMonitor monitor) {
DBPPropertySource propertySource = TabbedFolderPageForm.this.curPropertySource;
monitor.beginTask("Load '" + DBValueFormatting.getDefaultValueDisplayString(propertySource.getEditableValue(), DBDDisplayFormat.UI) + "' properties", allProps.size());
Map<DBPPropertyDescriptor, Object> 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);
}
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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) {
......
/*******************************************************************************
/*
* 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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册