| package org.eclipse.ptp.etfw.ui; |
| |
| import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; |
| import org.eclipse.swt.layout.GridData; |
| import org.eclipse.swt.layout.GridLayout; |
| |
| public abstract class AbstractToolConfigurationTab extends AbstractLaunchConfigurationTab { |
| public String getName() { |
| return null; |
| } |
| |
| /** |
| * Produces a new GridLayout based on provided arguments |
| * @param columns |
| * @param isEqual |
| * @param mh |
| * @param mw |
| * @return |
| */ |
| protected static GridLayout createGridLayout(int columns, boolean isEqual, int mh, |
| int mw) { |
| GridLayout gridLayout = new GridLayout(); |
| gridLayout.numColumns = columns; |
| gridLayout.makeColumnsEqualWidth = isEqual; |
| gridLayout.marginHeight = mh; |
| gridLayout.marginWidth = mw; |
| return gridLayout; |
| } |
| |
| /** |
| * Creates a new GridData based on provided style and space arguments |
| * @param style |
| * @param space |
| * @return |
| */ |
| protected static GridData spanGridData(int style, int space) { |
| GridData gd = null; |
| if (style == -1) { |
| gd = new GridData(); |
| } else { |
| gd = new GridData(style); |
| } |
| gd.horizontalSpan = space; |
| return gd; |
| } |
| |
| /** |
| * Treats empty strings as null |
| * @param text |
| * @return Contents of text, or null if text is the empty string |
| */ |
| protected String getFieldContent(String text) { |
| if ((text.trim().length() == 0) || text.equals("")) { |
| return null; |
| } |
| |
| return text; |
| } |
| } |