diff options
Diffstat (limited to 'common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FileChooserComboPane.java')
-rw-r--r-- | common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FileChooserComboPane.java | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FileChooserComboPane.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FileChooserComboPane.java new file mode 100644 index 0000000000..bae31806c6 --- /dev/null +++ b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FileChooserComboPane.java @@ -0,0 +1,105 @@ +/******************************************************************************* +* Copyright (c) 2010 Oracle. 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: +* Oracle - initial API and implementation +*******************************************************************************/ +package org.eclipse.jpt.common.ui.internal.widgets; + +import java.util.Arrays; +import java.util.List; + +import org.eclipse.jpt.utility.internal.StringConverter; +import org.eclipse.jpt.utility.internal.model.value.SimpleListValueModel; +import org.eclipse.jpt.utility.model.Model; +import org.eclipse.jpt.utility.model.value.ListValueModel; +import org.eclipse.jpt.utility.model.value.PropertyValueModel; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; + +/** + * This chooser allows the user to choose a file when browsing. + * <p> + * Here the layout of this pane: + * <pre> + * ----------------------------------------------------------------------------- + * | ---------------------------------------------------- ------------- | + * | Label: | I |v| | | Browse... | | + * | ---------------------------------------------------- ------------- | + * -----------------------------------------------------------------------------</pre> + * + * @version 3.0 + * @since 3.0 + */ +public abstract class FileChooserComboPane<T extends Model> extends FileChooserPane<T> +{ + /** + * Creates a new <code>FileChooserComboPane</code>. + * + * @param parentPane The parent pane of this one + * @param parent The parent container + */ + public FileChooserComboPane(Pane<? extends T> parentPane, + Composite parent) { + + super(parentPane, parent); + } + + /** + * Creates a new <code>FileChooserComboPane</code>. + * + * @param parentPane The parent container of this one + * @param subjectHolder The holder of this pane's subject + * @param parent The parent container + */ + public FileChooserComboPane(Pane<?> parentPane, + PropertyValueModel<? extends T> subjectHolder, + Composite parent) { + + super(parentPane, subjectHolder, parent); + } + + @Override + protected Control addMainControl(Composite container) { + + return addEditableCombo( + container, + this.buildListHolder(), + this.getTextHolder(), + this.buildStringConverter() + ); + } + + /** + * Creates the list holder of the combo box. + */ + protected ListValueModel<String> buildListHolder() { + return new SimpleListValueModel<String>( + this.buildDefaultList() + ); + } + + /** + * Creates the default list of the combo box. + */ + protected List<String> buildDefaultList() { + return Arrays.asList(this.getDefaultString()); + } + + /** + * Returns the default value of the combo box. + */ + protected abstract String getDefaultString(); + + /** + * The converter responsible to transform each combo box item + * into a string representation + */ + protected StringConverter<String> buildStringConverter() { + return StringConverter.Default.<String>instance(); + } + +}
\ No newline at end of file |