constraints

JavaFX TreeView TreeColumn auto-size to fit content

China☆狼群 提交于 2019-11-30 05:46:45
问题 I have been trying to figure out how to auto-size TreeView columns to fit their content for a while now. This has been asked before, but the response was minimal and not acceptable. [javafx column in tableview auto fit size Curiously, the behavior I'm looking for is exactly what happens when you double-click a column resize line in TableView. However, I have been unable to figure out how this occurs when looking through the JavaFX source code. Does anyone know how/where the double-click

Variable field in a constraint annotation

早过忘川 提交于 2019-11-30 05:14:59
I need to create a custom constraint annotation which can access the value of another field of my bean. I'll use this annotation to validate the field because it depends on the value of the other but the way I define it the compiler says "The value for annotation attribute" of my field "must be a constant expression". I've defined it in this way: @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) @Constraint(validatedBy=EqualsFieldValidator.class) @Documented public @interface EqualsField { public String field(); String message() default "{com.myCom.annotations.EqualsField.message}

Check Constraint - Subqueries are not allowed in this context

╄→гoц情女王★ 提交于 2019-11-30 04:46:29
问题 I tried to add a Check Constraint and I have only failed so far. What would be the way to get around this: Msg 1046, Level 15, State 1, Line 6 Subqueries are not allowed in this context. Only scalar expressions are allowed. This is the code: ALTER TABLE dbo.PropertySeasonDiscount ADD CONSTRAINT [CC_PropertySeasonDiscount_MadeFrom_MadeTo] CHECK ( (SELECT COUNT(PropertySeasonDiscountId) FROM dbo.PropertySeasonDiscounts apsdeb WHERE (apsdeb.PropertySeasonId = PropertySeasonId) AND ( (apsdeb

C# Generic constraints to include value types AND strings

我与影子孤独终老i 提交于 2019-11-30 04:40:59
I'm trying to write an extension method on IEnumerable that will only apply to value types and strings. public static string MyMethod<T>(this IEnumerable<T> source) where T : struct, string However 'string' is not a valid constraint as it is a sealed class. Is there any way to do this? Edit: What I'm actually trying to do is prepare a list of values for an "IN" clause in a dynamically constructed SQL. I have lots of instances of code such as the following that I want to clean up: sb.AppendLine(string.Format("AND value IN ({0})", string.Join(",", Values.Select(x => x.ToSQL()).ToArray())));

Can an SQL constraint be used to prevent a particular value being changed when a condition holds?

吃可爱长大的小学妹 提交于 2019-11-30 04:18:31
问题 I know that SQL constraints can force data to meet validity criteria. However, what about criteria such as "Student's grade can only be updated when the 'finalised' flag is false"? Do such update criteria have to be handled by the application? 回答1: Short answer: No, SQL constraints cannot in themselves prevent a change to column Grade when Finalized is 'true' (but allow a change otherwise). There are several kinds of SQL constraints: CHECK, DEFAULT, NOT NULL, UNIQUE, Primary Key, and Foreign

Fire trigger on update of columnA or ColumnB or ColumnC

北城余情 提交于 2019-11-30 03:55:26
I have the code to fire a trigger only on an update of a single specific column. The trigger is used to fire a function that will raise a postgres "notify" event, which I am listening for and will need to test and validate the newly input details. There are many values on the account_details table which could be change which do not require an account validate, so a trigger on AFTER UPDATE only (without a when) is no good. CREATE TRIGGER trigger_update_account_details AFTER UPDATE ON account_details FOR EACH ROW WHEN (OLD.email IS DISTINCT FROM NEW.email) EXECUTE PROCEDURE notify_insert_account

iOS: Autolayout causing UIScrollView to not scroll

倾然丶 夕夏残阳落幕 提交于 2019-11-30 02:52:11
问题 I have set up a UIScrollView with which I want to display 12 images (only 8 fit on screen) laid out horizontally. In the following image you can see the problem I'm having (which makes my scroll view not scroll), my constraints and the UIScrollView which I have added on storyboard: I have called the following method on -(void)viewDidLoad , where I "set up"my scrollview (itemList is my scroll view property and itemNames a array with the images'names): - (void)setupHorizontalScrollView { self

How do I define a generic class that implements an interface and constrains the type parameter?

百般思念 提交于 2019-11-30 01:12:15
class Sample<T> : IDisposable // case A { public void Dispose() { throw new NotImplementedException(); } } class SampleB<T> where T : IDisposable // case B { } class SampleC<T> : IDisposable, T : IDisposable // case C { public void Dispose() { throw new NotImplementedException(); } } Case C is the combination of case A and case B. Is that possible? How to make case C right? First the implemented interfaces, then the generic type constraints separated by where : class SampleC<T> : IDisposable where T : IDisposable // case C { // ↑ public void Dispose() { throw new NotImplementedException(); } }

How to restrict T to value types using a constraint?

拥有回忆 提交于 2019-11-30 00:48:06
问题 I want to restrict the possible types N can take-on using a constraint. I wish to restrict N to be either a int or a decimal. public static Chart PopulateInto<T, N>(List<T> yAxis, List<N> xAxis) where N : int, decimal { // Do stuff here } Any help appreciated... 回答1: Unfortunately, it is not possible to specify generic type constraints that only allow specific value types. More to the point, it wouldn't make much sense even if it was allowed. You're allowed to specify a class as a generic

Why we can’t use sealed classes as generic constraints?

徘徊边缘 提交于 2019-11-30 00:27:54
问题 Can you guess what is the reason to not allow sealed classes for type-constraints in generics? I only have one explanation is to give opportunity to use naked constraints. 回答1: If the class is sealed it cannot be inherited. If it cannot be inherited it'd be the only type valid for the generic type argument [assuming if allowed to be a type argument]. If it is the only generic type argument then there's no point in making it generic! You can simply code against the type in non-generic class.