Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 168911 Details for
Bug 194168
[Preferences][JFace] implement validation for ComboFieldEditor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
solution
patch.txt (text/plain), 2.88 KB, created by
Michael Seele
on 2010-05-18 08:47:42 EDT
(
hide
)
Description:
solution
Filename:
MIME Type:
Creator:
Michael Seele
Created:
2010-05-18 08:47:42 EDT
Size:
2.88 KB
patch
obsolete
>--- ComboFieldEditor.java 2010-05-13 08:45:38.000000000 +0200 >+++ ComboFieldEditor.java.new 2010-05-18 14:43:34.000000000 +0200 >@@ -45,6 +45,17 @@ > */ > private String[][] fEntryNamesAndValues; > >+ /** >+ * Indicates whether the empty selection is legal; >+ * <code>true</code> by default. >+ */ >+ private boolean emptySelectionAllowed = true; >+ >+ /** >+ * Cached valid state. >+ */ >+ private boolean isValid; >+ > /** > * Create the combo box field editor. > * >@@ -217,4 +228,82 @@ > super.setEnabled(enabled, parent); > getComboBoxControl(parent).setEnabled(enabled); > } >+ >+ /* (non-Javadoc) >+ * Method declared on FieldEditor. >+ */ >+ public boolean isValid() { >+ return isValid; >+ } >+ >+ /* (non-Javadoc) >+ * Method declared on FieldEditor. >+ */ >+ protected void refreshValidState() { >+ isValid = checkState(); >+ } >+ >+ /** >+ * Hook for subclasses to do specific state checks. >+ * <p> >+ * The default implementation of this framework method does >+ * nothing and returns <code>true</code>. Subclasses should >+ * override this method to specific state checks. >+ * </p> >+ * >+ * @return <code>true</code> if the field value is valid, >+ * and <code>false</code> if invalid >+ */ >+ protected boolean doCheckState() { >+ return true; >+ } >+ >+ /** >+ * Checks whether the combo input field contains a valid value or not. >+ * >+ * @return <code>true</code> if the field value is valid, >+ * and <code>false</code> if invalid >+ */ >+ protected boolean checkState() { >+ boolean result = false; >+ if (emptySelectionAllowed) { >+ result = true; >+ } >+ >+ if (fCombo == null) { >+ result = false; >+ } >+ >+ int selectionIndex = fCombo.getSelectionIndex(); >+ >+ result = (selectionIndex != -1) || emptySelectionAllowed; >+ >+ // call hook for subclasses >+ result = result && doCheckState(); >+ >+ return result; >+ } >+ >+ /** >+ * Returns whether an empty selection is a valid value. >+ * >+ * @return <code>true</code> if an empty selection is a valid value, and >+ * <code>false</code> if an empty selection is invalid >+ * @see #setEmptySelectionAllowed >+ */ >+ public boolean isEmptySelectionAllowed() { >+ return emptySelectionAllowed; >+ } >+ >+ /** >+ * Sets whether the empty selection is a valid value or not. >+ * >+ * @param b <code>true</code> if the empty selection is allowed, >+ * and <code>false</code> if it is considered invalid >+ */ >+ public void setEmptySelectionAllowed(boolean b) { >+ emptySelectionAllowed = b; >+ } >+ >+ > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 194168
: 168911