diff options
author | Uwe Stieber | 2013-04-09 11:50:57 +0000 |
---|---|---|
committer | Uwe Stieber | 2013-04-09 11:51:29 +0000 |
commit | a7b0a89e1bbebb3d8bab0b3a07a3e895aff9822e (patch) | |
tree | d1d8f3c51fe33c2401cee6e8be69c88f5f0f760b /target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src | |
parent | c4d1ff0c3cf8d73fcdf57e7a3c269c0a4bf34553 (diff) | |
download | org.eclipse.tcf-a7b0a89e1bbebb3d8bab0b3a07a3e895aff9822e.tar.gz org.eclipse.tcf-a7b0a89e1bbebb3d8bab0b3a07a3e895aff9822e.tar.xz org.eclipse.tcf-a7b0a89e1bbebb3d8bab0b3a07a3e895aff9822e.zip |
Target Explorer: Change default layout for the button part of a BaseEditBrowseTextControl. Adjust transport type combo box length.
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src')
-rw-r--r-- | target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/controls/TransportSectionTypeControl.java | 161 |
1 files changed, 91 insertions, 70 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/controls/TransportSectionTypeControl.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/controls/TransportSectionTypeControl.java index bfc2c1753..1be26e87f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/controls/TransportSectionTypeControl.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/controls/TransportSectionTypeControl.java @@ -1,70 +1,91 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.ui.editor.controls;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.tcf.te.tcf.ui.controls.TransportTypeControl;
-import org.eclipse.tcf.te.tcf.ui.editor.sections.TransportSection;
-import org.eclipse.tcf.te.ui.jface.interfaces.IValidatingContainer;
-
-/**
- * Transport section transport type control implementation.
- */
-public class TransportSectionTypeControl extends TransportTypeControl {
- // Reference to the parent transport section
- private final TransportSection transportSection;
-
- /**
- * Constructor.
- *
- * @param transportSection The parent transport section. Must not be <code>null</code>.
- */
- public TransportSectionTypeControl(TransportSection transportSection) {
- super(null);
-
- Assert.isNotNull(transportSection);
- this.transportSection = transportSection;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- @Override
- public void widgetSelected(SelectionEvent e) {
- TransportSectionTypePanelControl transportTypePanelControl = (TransportSectionTypePanelControl)transportSection.getAdapter(TransportSectionTypePanelControl.class);
-
- if (transportTypePanelControl != null) {
- transportTypePanelControl.showConfigurationPanel(getSelectedTransportType());
-
- IValidatingContainer validatingContainer = getValidatingContainer();
- if (validatingContainer != null) validatingContainer.validate();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.controls.BaseDialogPageControl#getValidatingContainer()
- */
- @Override
- public IValidatingContainer getValidatingContainer() {
- Object container = transportSection.getManagedForm().getContainer();
- return container instanceof IValidatingContainer ? (IValidatingContainer)container : null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#modifyText(org.eclipse.swt.events.ModifyEvent)
- */
- @Override
- public void modifyText(ModifyEvent e) {
- super.modifyText(e);
- transportSection.dataChanged(e);
- }
-}
+/******************************************************************************* + * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.ui.editor.controls; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.tcf.te.tcf.ui.controls.TransportTypeControl; +import org.eclipse.tcf.te.tcf.ui.editor.sections.TransportSection; +import org.eclipse.tcf.te.ui.jface.interfaces.IValidatingContainer; +import org.eclipse.tcf.te.ui.swt.SWTControlUtil; + +/** + * Transport section transport type control implementation. + */ +public class TransportSectionTypeControl extends TransportTypeControl { + // Reference to the parent transport section + private final TransportSection transportSection; + + /** + * Constructor. + * + * @param transportSection The parent transport section. Must not be <code>null</code>. + */ + public TransportSectionTypeControl(TransportSection transportSection) { + super(null); + + Assert.isNotNull(transportSection); + this.transportSection = transportSection; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#widgetSelected(org.eclipse.swt.events.SelectionEvent) + */ + @Override + public void widgetSelected(SelectionEvent e) { + TransportSectionTypePanelControl transportTypePanelControl = (TransportSectionTypePanelControl)transportSection.getAdapter(TransportSectionTypePanelControl.class); + + if (transportTypePanelControl != null) { + transportTypePanelControl.showConfigurationPanel(getSelectedTransportType()); + + IValidatingContainer validatingContainer = getValidatingContainer(); + if (validatingContainer != null) validatingContainer.validate(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.controls.BaseDialogPageControl#getValidatingContainer() + */ + @Override + public IValidatingContainer getValidatingContainer() { + Object container = transportSection.getManagedForm().getContainer(); + return container instanceof IValidatingContainer ? (IValidatingContainer)container : null; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#modifyText(org.eclipse.swt.events.ModifyEvent) + */ + @Override + public void modifyText(ModifyEvent e) { + super.modifyText(e); + transportSection.dataChanged(e); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#doAdjustEditFieldControlLayoutData(org.eclipse.swt.layout.GridData) + */ + @Override + protected void doAdjustEditFieldControlLayoutData(GridData layoutData) { + super.doAdjustEditFieldControlLayoutData(layoutData); + + int maxWidth = -1; + for (String type : getTransportTypes()) { + maxWidth = Math.max(type.length(), maxWidth); + } + + if (maxWidth != -1) { + layoutData.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; + layoutData.grabExcessHorizontalSpace = false; + layoutData.widthHint = SWTControlUtil.convertWidthInCharsToPixels(getEditFieldControl(), maxWidth + 4); + } + } +} |