Search Results

Search found 7420 results on 297 pages for 'generic collections'.

Page 15/297 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • How can I modify my classes to use it's collections in WPF TreeView

    - by Victor
    Hello, i'am trying to modify my objects to make hierarchical collection model. I need help. My objects are Good and GoodCategory: public class Good { int _ID; int _GoodCategory; string _GoodtName; public int ID { get { return _ID; } } public int GoodCategory { get { return _GoodCategory; } set { _GoodCategory = value; } } public string GoodName { get { return _GoodName; } set { _GoodName = value; } } public Good(IDataRecord record) { _ID = (int)record["ID"]; _GoodtCategory = (int)record["GoodCategory"]; } } public class GoodCategory { int _ID; string _CategoryName; public int ID { get { return _ID; } } public string CategoryName { get { return _CategoryName; } set { _CategoryName = value; } } public GoodCategory(IDataRecord record) { _ID = (int)record["ID"]; _CategoryName = (string)record["CategoryName"]; } } And I have two Collections of these objects: public class GoodsList : ObservableCollection<Good> { public GoodsList() { string goodQuery = @"SELECT `ID`, `ProductCategory`, `ProductName`, `ProductFullName` FROM `products`;"; using (MySqlConnection conn = ConnectToDatabase.OpenDatabase()) { if (conn != null) { MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = productQuery; MySqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Add(new Good(rdr)); } } } } } public class GoodCategoryList : ObservableCollection<GoodCategory> { public GoodCategoryList () { string goodQuery = @"SELECT `ID`, `CategoryName` FROM `product_categoryes`;"; using (MySqlConnection conn = ConnectToDatabase.OpenDatabase()) { if (conn != null) { MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = productQuery; MySqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Add(new GoodCategory(rdr)); } } } } } So I have two collections which takes data from the database. But I want to use thats collections in the WPF TreeView with HierarchicalDataTemplate. I saw many post's with examples of Hierarlichal Objects, but I steel don't know how to make my objects hierarchicaly. Please help.

    Read the article

  • Proper usage of Java Weak Reference in case of nested collections

    - by Tong Wang
    I need to define a weak reference Map, whose value is a Set. I use Google collections' MapMaker, like this: Map<Class<? extends Object>, Set<Foo>> map = new MapMaker().weakKeys().weakValues().makeMap(); So, for Set<Foo>, can I use a normal HashSet? Or, do I have to create a weak HashSet, like this: Collections.newSetFromMap(new WeakHashMap<Foo, Boolean>()); And why? Another question, the key of my map is Class objects, when will a Class object become weakly reachable? In other words, what is the lifetime of a Class object? Thanks.

    Read the article

  • Java Collections.Rotate with an array doesn't work

    - by steve_72
    I have the following java code: import java.util.Arrays; import java.util.Collections; public class Test { public static void main(String[] args) { int[] test = {1,2,3,4,5}; Collections.rotate(Arrays.asList(test), -1); for(int i = 0; i < test.length; i++) { System.out.println(test[i]); } } } I want the array to be rotated, but the output I get is 1 2 3 4 5 Why is this? And is there an alternative solution?

    Read the article

  • dist-upgrade runs and completes but current kernel stays the same

    - by jaguare22
    I think that my system is staying at an older kernel version. It seems to update when I run dist-upgrade but the current kernel version doesn't change. Is it possible the system is set to install new kernel updates but only load an older version at start up? $ uname -a Linux HTPC 3.2.0-32-generic #51-Ubuntu SMP Wed Sep 26 21:32:50 UTC 2012 i686 athlon i386 GNU/Linux $ dpkg --list | grep linux-image ii linux-image-3.2.0-32-generic 3.2.0-32.51 Linux kernel image for version 3.2.0 on 32 bit x86 SMP ii linux-image-3.2.0-32-generic-pae 3.2.0-32.51 Linux kernel image for version 3.2.0 on 32 bit x86 SMP ii linux-image-3.2.0-32-virtual 3.2.0-32.51 Linux kernel image for version 3.2.0 on 32 bit x86 Virtual Guests dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' linux-headers-3.2.0-36 linux-headers-3.2.0-36-generic-pae linux-headers-3.2.0-37 linux-headers-3.2.0-37-generic-pae linux-headers-3.2.0-38 linux-headers-3.2.0-38-generic-pae linux-headers-3.2.0-39 linux-headers-3.2.0-39-generic-pae linux-headers-3.2.0-40 linux-headers-3.2.0-40-generic-pae linux-headers-3.2.0-41 linux-headers-3.2.0-41-generic-pae linux-headers-3.2.0-43 linux-headers-3.2.0-43-generic-pae linux-headers-3.2.0-44 linux-headers-3.2.0-44-generic-pae linux-headers-3.2.0-45 linux-headers-3.2.0-45-generic-pae linux-headers-3.2.0-48 linux-headers-3.2.0-48-generic-pae

    Read the article

  • Writing a synchronized thread-safety wrapper for NavigableMap

    - by polygenelubricants
    java.util.Collections currently provide the following utility methods for creating synchronized wrapper for various collection interfaces: synchronizedCollection(Collection<T> c) synchronizedList(List<T> list) synchronizedMap(Map<K,V> m) synchronizedSet(Set<T> s) synchronizedSortedMap(SortedMap<K,V> m) synchronizedSortedSet(SortedSet<T> s) Analogously, it also has 6 unmodifiedXXX overloads. The glaring omission here are the utility methods for NavigableMap<K,V>. It's true that it extends SortedMap, but so does SortedSet extends Set, and Set extends Collection, and Collections have dedicated utility methods for SortedSet and Set. Presumably NavigableMap is a useful abstraction, or else it wouldn't have been there in the first place, and yet there are no utility methods for it. So the questions are: Is there a specific reason why Collections doesn't provide utility methods for NavigableMap? How would you write your own synchronized wrapper for NavigableMap? Glancing at the source code for OpenJDK version of Collections.java seems to suggest that this is just a "mechanical" process Is it true that in general you can add synchronized thread-safetiness feature like this? If it's such a mechanical process, can it be automated? (Eclipse plug-in, etc) Is this code repetition necessary, or could it have been avoided by a different OOP design pattern?

    Read the article

  • Generic Sorting using C# and Lambda Expression

    - by Haitham Khedre
    Download : GenericSortTester.zip I worked in this class from long time and I think it is a nice piece of code that I need to share , it might help other people searching for the same concept. this will help you to sort any collection easily without needing to write special code for each data type , however if you need special ordering you still can do it , leave a comment and I will see if I need to write another article to cover the other cases. I attached also a fully working example to make you able to see how do you will use that .     public static class GenericSorter { public static IOrderedEnumerable<T> Sort<T>(IEnumerable<T> toSort, Dictionary<string, SortingOrder> sortOptions) { IOrderedEnumerable<T> orderedList = null; foreach (KeyValuePair<string, SortingOrder> entry in sortOptions) { if (orderedList != null) { if (entry.Value == SortingOrder.Ascending) { orderedList = orderedList.ApplyOrder<T>(entry.Key, "ThenBy"); } else { orderedList = orderedList.ApplyOrder<T>(entry.Key,"ThenByDescending"); } } else { if (entry.Value == SortingOrder.Ascending) { orderedList = toSort.ApplyOrder<T>(entry.Key, "OrderBy"); } else { orderedList = toSort.ApplyOrder<T>(entry.Key, "OrderByDescending"); } } } return orderedList; } private static IOrderedEnumerable<T> ApplyOrder<T> (this IEnumerable<T> source, string property, string methodName) { ParameterExpression param = Expression.Parameter(typeof(T), "x"); Expression expr = param; foreach (string prop in property.Split('.')) { expr = Expression.PropertyOrField(expr, prop); } Type delegateType = typeof(Func<,>).MakeGenericType(typeof(T), expr.Type); LambdaExpression lambda = Expression.Lambda(delegateType, expr, param); MethodInfo mi = typeof(Enumerable).GetMethods().Single( method => method.Name == methodName && method.IsGenericMethodDefinition && method.GetGenericArguments().Length == 2 && method.GetParameters().Length == 2) .MakeGenericMethod(typeof(T), expr.Type); return (IOrderedEnumerable<T>)mi.Invoke (null, new object[] { source, lambda.Compile() }); } } .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

    Read the article

  • Generic log analyzer that produces reports

    - by Eugene
    About 600 customers use our application. We have very detailed logs for everything that happens in the application, from changes in the data model, memory and CPU/GPU usage to clicks on the UI elements. We want to be able to parse the logs coming from these customers and analyze them to understand how users use our application and what happens internally in the application. Is there a log analyzer that can produce such reports automatically?

    Read the article

  • Some More New ADF Features in JDeveloper 11.1.2

    - by Steven Davelaar
    The official list of new features in JDeveloper 11.1.2 is documented here. While playing with JDeveloper 11.1.2 and scanning the web user interface developer's guide for 11.1.2, I noticed some additional new features in ADF Faces, small but might come in handy:  You can use the af:formatString and af:formatNamed constructs in EL expressions to use substituation variables. For example: <af:outputText value="#{af:formatString('The current user is: {0}',someBean.currentUser)}"/> See section 3.5.2 in web user interface guide for more info. A new ADF Faces Client Behavior tag: af:checkUncommittedDataBehavior. See section 20.3 in web user interface guide for more info. For this tag to work, you also need to set the  uncommittedDataWarning  property on the af:document tag. And this property has quite some issues as you can read here. I did a quick test, the alert is shown for a button that is on the same page, however, if you have a menu in a shell page with dynamic regions, then clicking on another menu item does not raise the alert if you have pending changes in the currently displayed region. For now, the JHeadstart implementation of pending changes still seems the best choice (will blog about that soon). New properties on the af:document tag: smallIconSource creates a so-called favicon that is displayed in front of the URL in the browser address bar. The largeIconSource property specifies the icon used by a mobile device when bookmarking the page to the home page. See section 9.2.5 in web user interface guide for more info. Also notice the failedConnectionText property which I didn't know but was already available in JDeveloper 11.1.1.4. The af:showDetail tag has a new property handleDisclosure which you can set to client for faster rendering. In JDeveloper 11.1.1.x, an expression like #{bindings.JobId.inputValue} would return the internal list index number when JobId was a list binding. To get the actual JobId attribute value, you needed to use #{bindings.JobId.attributeValue}. In JDeveloper 11.1.2 this is no longer needed, the #{bindings.JobId.inputValue} expression will return the attribute value corresponding with the selected index in the choice list. Did you discover other "hidden" new features? Please add them as comment to this blog post so everybody can benefit. 

    Read the article

  • Designing generic render/graphics component in C++?

    - by s73v3r
    I'm trying to learn more about Component Entity systems. So I decided to write a Tetris clone. I'm using the "style" of component-entity system where the Entity is just a bag of Components, the Components are just data, a Node is a set of Components needed to accomplish something, and a System is a set of methods that operates on a Node. All of my components inherit from a basic IComponent interface. I'm trying to figure out how to design the Render/Graphics/Drawable Components. Originally, I was going to use SFML, and everything was going to be good. However, as this is an experimental system, I got the idea of being able to change out the render library at will. I thought that since the Rendering would be fairly componentized, this should be doable. However, I'm having problems figuring out how I would design a common Interface for the different types of Render Components. Should I be using C++ Template types? It seems that having the RenderComponent somehow return it's own mesh/sprite/whatever to the RenderSystem would be the simplest, but would be difficult to generalize. However, letting the RenderComponent just hold on to data about what it would render would make it hard to re-use this component for different renderable objects (background, falling piece, field of already fallen blocks, etc). I realize this is fairly over-engineered for a regular Tetris clone, but I'm trying to learn about component entity systems and making interchangeable components. It's just that rendering seems to be the hardest to split out for me.

    Read the article

  • JHeadstart search with default values

    - by christian.bischof
    JHeadstart has a powerful generator for ADF Faces pages. One of the features of the generator is the generation of search functionality into a page. The search functionality offers a "Quicksearch" with a single search item and an "Advanced Search" for multiple search criteria. Sometimes it would be nice to have initial values for the search criteria, but this is not supplied by JHeadstart by default.

    Read the article

  • Embeding a generic google search with autocomplete - not a custom site search

    - by picxelplay
    Most people's home page is google.com. My homepage is just a custom html page hosted on my computer. I do this because I am a web developer, and I have several projects that I work on a one time, so I like to have quick links to all of them. On that page I usually just have a Link to google.com for when I want to search. But below all of my quick links, I want to add a google search box (with Autocompletions). I first used a simple iframe to embed google.com into the page, but then my search results were confined to that iframe. I wanted to search for something, then my results would open in a new tab. I then came across this code snippet but it doesn't have Autocompletions: http://www.refactory.org/s/google_search/view/2 How can I add Autocompletions to this? Or is there a better way of doing it? Thanks in advance for any advice

    Read the article

  • Embeding a generic google search with autocomplete - not a custom site search

    - by picxelplay
    Most people's home page is google.com. My homepage is just a custom html page hosted on my computer. I do this because I am a web developer, and I have several projects that I work on a one time, so I like to have quick links to all of them. On that page I usually just have a Link to google.com for when I want to search. But below all of my quick links, I want to add a google search box (with Autocompletions). I first used a simple iframe to embed google.com into the page, but then my search results were confined to that iframe. I wanted to search for something, then my results would open in a new tab. I then came across this code snippet but it doesn't have Autocompletions: http://www.refactory.org/s/google_search/view/2 How can I add Autocompletions to this? Or is there a better way of doing it? Thanks in advance for any advice

    Read the article

  • schema.org specification for generic pages or posts on a CMS

    - by NateWr
    I'm trying to determine the best possible schema.org type to declare for the content section in the template of a content management system, which will handle regular news posts for small, local hospitality businesses. The type should represent the content of that page, which is likely to be a wide range of things. The description for Article pretty strongly encourages its use to be limited to the articles of a publication. For purely semantic reasons, I'm not sure if Blog is appropriate in this case -- businesses won't be creating typical "blog" content but are more likely to be writing about upcoming events, special deals, awards, etc. Would Webpage be appropriate in this instance? Although I'm a fan of the schema.org concept, I frequently find myself unsure how broadly or narrowly I'm meant to infer the meaning of a type. In such cases, is it safe to use a high-level element, such as CreativeWork, or does this blunt the usefulness of the markup?

    Read the article

  • Generic Content Player?

    - by Jantire
    The general idea on the web appears to be that video/audio are to be separated with plain text. By separated, I mean you have a place that plays video/audio and a place that you read text. This is because it is widely understood that they are vastly different. However, audio and video are just another way of communication, just like text. So why do we separate the two even if they are nearly the same thing? Correct me if I'm wrong but, most tutorials are either plain text how-to's (wiki-style) or visual/auditory instructional videos (YouTube). Why aren't the two combined? Or, if it's already been done can someone reply with the link? This might be bordering off-topic and if it is off-topic then please point me to the right place so it won't be. This might also appear to be an obvious question, however I'm not sure if this subject has really been deeply thought-out by more than a few individuals.

    Read the article

  • which collection should I use

    - by Masna
    Hello, I have a number of custom objects of type X. X has a number of parameters and must be unique in the collection. (I created my own equals method based on the custom parameters to examine this) In each object of type x, I have a list of objects y. I want to add/remove/modify easily an object y. For example: To write the add method, it would be something like add(objTypeX, objTypeY) I would check or the collections already has a objTypeX. If so: i would add the objTypeY to the already existing objTypeX else: i would create objTypeX and add objTypeY to this object. To modify an objTypeY, it would be something like(objTypeX, objTypeY, newobjTypeY) I would get objTypeX out of the collections and modify objTypeY to newobjTypeY Which collections should I use? I tried with hashset but i can get a specific object out of the list, without run down the list till I find that object. I develop this in vb.net 3.5

    Read the article

  • Direct comparator in Java out of the box

    - by KARASZI István
    I have a method which needs a Comparator for one of its parameters. I would like to pass a Comparator which does a normal comparison and a reverse comparator which does in reverse. java.util.Collections provides a reverseOrder() this is good for the reverse comparison, but I could not find any normal Comparator. The only solution what came into my mind is Collections.reverseOrder(Collections.reverseOrder()). but I don't like it because the double method calling inside. Of course I could write a NormalComparator like this: public class NormalComparator<T extends Comparable> implements Comparator<T> { public int compare(T o1, T o2) { return o1.compareTo(o2); } } But I'm really surprised that Java doesn't have a solution for this out of the box.

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >