提交 076f159f 编写于 作者: S Serge Rider

#10819 HANA UI fixes

上级 a05bfd35
......@@ -4,7 +4,6 @@ Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.jkiss.dbeaver.ext.hana.ui;singleton:=true
Bundle-Version: 1.0.1.qualifier
Bundle-Release-Date: 20201019
Bundle-Activator: org.jkiss.dbeaver.ext.hana.ui.HANAActivator
Require-Bundle: org.eclipse.ui,
org.jkiss.dbeaver.ext.hana,
org.jkiss.dbeaver.ui.editors.connection,
......
Bundle-Vendor = DBeaver Corp
Bundle-Name = DBeaver HANA UI
hana.dialog.connection.header = SAP HANA Connection Settings
\ No newline at end of file
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2020 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.hana.ui;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class HANAActivator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.jkiss.dbeaver.ext.hana.ui";
// The shared instance
private static HANAActivator plugin;
public HANAActivator() {
}
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
@Override
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
public static HANAActivator getDefault() {
return plugin;
}
public static ImageDescriptor getImageDescriptor(String path) {
return imageDescriptorFromPlugin(PLUGIN_ID, path);
}
}
......@@ -16,21 +16,14 @@
*/
package org.jkiss.dbeaver.ext.hana.ui.views;
import java.util.Locale;
import java.util.Map.Entry;
import org.eclipse.jface.dialogs.IDialogPage;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.jkiss.dbeaver.ext.hana.ui.HANAActivator;
import org.eclipse.swt.widgets.*;
import org.jkiss.dbeaver.ext.hana.ui.internal.HANAEdition;
import org.jkiss.dbeaver.ext.hana.ui.internal.HANAMessages;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
......@@ -41,6 +34,9 @@ import org.jkiss.dbeaver.ui.dialogs.connection.ConnectionPageWithAuth;
import org.jkiss.dbeaver.ui.dialogs.connection.DriverPropertiesDialogPage;
import org.jkiss.utils.CommonUtils;
import java.util.Locale;
import java.util.Map.Entry;
/*
* when edition==GENERIC, don't show/touch any driver properties for
* - compatibility with previous configuration
......@@ -73,23 +69,25 @@ public class HANAConnectionPage extends ConnectionPageWithAuth implements ICompo
private String instanceValue;
private String databaseValue;
private static ImageDescriptor logoImage = HANAActivator.getImageDescriptor("icons/sap_hana_logo.png"); //$NON-NLS-1$
private DriverPropertiesDialogPage driverPropsPage;
private final Image logoImage;
public HANAConnectionPage() {
driverPropsPage = new DriverPropertiesDialogPage(this);
logoImage = createImage("icons/sap_hana_logo.png"); //$NON-NLS-1$
}
@Override
public void dispose() {
super.dispose();
UIUtils.dispose(logoImage);
}
@Override
public void createControl(Composite composite) {
setImageDescriptor(logoImage);
public Image getImage() {
return logoImage;
}
@Override
public void createControl(Composite composite) {
Composite settingsGroup = new Composite(composite, SWT.NONE);
settingsGroup.setLayout(new GridLayout(1, false));
settingsGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
......@@ -105,14 +103,13 @@ public class HANAConnectionPage extends ConnectionPageWithAuth implements ICompo
hostText = UIUtils.createLabelText(addrGroup, HANAMessages.label_host, "");
portText = UIUtils.createLabelText(addrGroup, HANAMessages.label_port, "");
GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
gd.widthHint = UIUtils.getFontHeight(portText) * 5;
portText.setLayoutData(gd);
portText.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
((GridData)portText.getLayoutData()).widthHint = UIUtils.getFontHeight(portText) * 5;
portText.addVerifyListener(UIUtils.getIntegerVerifyListener(Locale.getDefault()));
instanceLabel = UIUtils.createControlLabel(addrGroup, HANAMessages.label_instance);
instanceText = new Text(addrGroup, SWT.BORDER);
instanceText.setLayoutData(gd);
instanceText.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
instanceText.addVerifyListener(UIUtils.getIntegerVerifyListener(Locale.getDefault()));
instanceText.setToolTipText(HANAMessages.tooltip_instance);
databaseLabel = UIUtils.createControlLabel(addrGroup, HANAMessages.label_database);
......@@ -224,7 +221,7 @@ public class HANAConnectionPage extends ConnectionPageWithAuth implements ICompo
@Override
public IDialogPage[] getSubPages(boolean extrasOnly, boolean forceCreate) {
return new IDialogPage[] { driverPropsPage };
return new IDialogPage[] { new DriverPropertiesDialogPage(this) };
}
private void editionUpdated() {
......@@ -241,12 +238,6 @@ public class HANAConnectionPage extends ConnectionPageWithAuth implements ICompo
edition = HANAEdition.fromTitle(editionCombo.getText());
// restore / set calculated new values
instanceLabel.setVisible(edition != HANAEdition.GENERIC);
instanceText.setVisible(edition != HANAEdition.GENERIC);
databaseLabel.setVisible(edition != HANAEdition.GENERIC);
databaseText.setVisible(edition != HANAEdition.GENERIC);
portText.setEditable(edition == HANAEdition.GENERIC || edition == HANAEdition.EXPRESS);
UIUtils.fixReadonlyTextBackground(portText);
switch (edition) {
......@@ -291,6 +282,20 @@ public class HANAConnectionPage extends ConnectionPageWithAuth implements ICompo
databaseText.setEditable(false);
}
UIUtils.fixReadonlyTextBackground(databaseText);
toggleControlVisibility(instanceLabel);
toggleControlVisibility(instanceText);
toggleControlVisibility(databaseLabel);
toggleControlVisibility(databaseText);
((Composite)getControl()).layout(true, true);
}
private void toggleControlVisibility(Control control) {
control.setVisible(edition != HANAEdition.GENERIC);
Object layoutData = control.getLayoutData();
if (layoutData instanceof GridData) {
((GridData) layoutData).exclude = (edition == HANAEdition.GENERIC);
}
}
private void instanceUpdated() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册