Marin Capranov

Ranch Hand
+ Follow
since Jan 31, 2020
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Marin Capranov

Well, the thing is I can go deeper than the second level. Is just me that I need that only. The problem is that I am working on a open source project and I am afraid that would be hard to implement your code.

The project is called Wiki JS.

Regarding the libraries, I can say that it uses Vue-apollo for queries and Lodash library for array and collection handling.

If you look at the parameters of the queries you can see the variable $parent. That one is responsible for finding the parent folders and checks whether there are any sub folder, files or not.

For ex: parent: 1, locale: this.locale will return the files if any that have the parent id as 1, and so it works to any other level. If a folder is as deep as third level and its parent ids would be, for example, 1 -> 2 - 3(our file) than in order to get that file we will have to assign 3 to the parent variable.

I ran into a problem that the parent variable accepts only one value, eventually will return only the items of on parent folder. I try now to see how to return all the files under any parent folder.
4 years ago
Hi!

I've got an array that contains the first level of items. For example:



Each one of them got an ID. To get that data I use graphql query:



As you can see it uses Lodash for array manipulation.

Now, I've got the items that belong to a specific folder. It is using another graphql query that gets the files for a particular folder based on the parent ID. Have a look:



As you can see, I've got two queries doing two jobs. 1st is to get the first level of items and the second is returning the items belonging to a particular folder based on the parent ID of the folder.

So eventually, I get something like that:



The thing I try to achieve is, I want to make all these structures as a single JS object:



The idea is I have at the moment 2 arrays. One for the first level of items and the second array is the child node containing the files to each parent folder.

How can combine these two arrays so I build the structure shown above?

The main developer of this project had used Lodash for that. Is there a way to accomplish that? Or it can be done with pure Javascript?
4 years ago
Hi,

I got a method that pulls the data from the database. The method has a parameter that it accepts and is important because depending on that it pulls different data from the database. Now I need a way to pull the data in a treeview form and I found that vuetify has it, but I don’t really get how to do that. Its examples show how to use it with already predefined data, but I have a dynamic one.

This is the method. So far I had to use v-list-group and loop through the results but is not as nice looking as the treeview. Also, there is a problem to expand it. If, for example, I got more subgroups. With v-treeview it seems to be all aligned nicely.



It is using graphql for pulling data. I want that data to be pulled in for of a treeview. How can I do that?
Yes, you are right I perfectly know that but for some reason, I just neglect it, maybe because I know that I work alone, yet, is true that names of the variables and all the rest make it easier to understand the code for me and for others. I periodically find code online and sometimes I have blood coming out of my eyes seeing it, and still, I do the same mistake =). Thanks for heads up! Cheers!
4 years ago
Oh my God! How I could be that blind. Thank you a lot, it solved the problem. God...
4 years ago
Hi and thank you for advice,

I have tried to do some changes, but all unlucky:

That's the method for creating model:



And that's the method that is meant to update the table:



Next is the mainframe and the button action listener where I try to call the updating method:

Mainframe:



and inside the mainframe I have the button action listener:



I find strange it because if I comment out the first call of the update method inside the mainframe, clicking on the button does not do anything, even though it is supposed to add the table and all. Honestly, I try all the way around and can't make update the content. It only does it when I exit and re-enter the program. Is something to do with the Event dispatch thread?

Thank you!
4 years ago
I don't really understand what is the issue of the model. As I said if I exit the program and re-enter it the table is updated. The thing is I want to update it while I am using the program, let's say press a button and refresh the table. Could you explain in more detail what you mean by setting the model? If I am not wrong I already do that and it refreshes the table, well not when I want though. Cheers!
4 years ago
HI there!

I have a code that updates the JTable only after the program is restarted, but how do I refresh the JTable without exiting the program? That must happen when I upload a file containing some data.

MainClass.class




That's the method that creates a table model:

MyTable.class



I want that to happen when I click on the upload file button.

MainClass.class




I guess there is something to do with the model?
4 years ago
Solved! I found that the error was in the parameters of the List of the geOnlyById method. The method returned int and I was checking if it contained string value.

That's the result:



if you can see the method initially was returning a List<Integer> and now is List<String>.

The condition is performing on string values:



Hope it clears out!
4 years ago
Solved by actually modifying the code a bit.
I used if statements inside the button, instead of a switch.

This how it looks in the end:



Now the Enum is seen when a value is set to it.

Sorry for inconvenience!

4 years ago
Hi guys, again.

I got a problem with the if/else statement. The thing returns always the "else" part. It is checking if the value is in the database or not. Funny thing is it works if I do not put inside an if statement, however when I enclose it it skips the if part and goes always to the else part which returns nothing. I use the logic inside an action performed method. Outside of it it seems to works just fine. Is there a problem with the threads or something?

That's the code:



That's an example where the code actually works but is not inside an action listener method:



The method inside the if condition:

Another class:



Why would the if statement work that strange? It always returns "ID does not exist! Try another" part even if without the if/ else condition it works just fine.

Working code:

4 years ago
Hi guys,

I got a problem with the action listener method. The thing is I got an Enum class and it contains three possible states of the buttons: Add, remove, and update. I want to use this for a switch. The Enum is set inside an action performed method, but it, in the end, I get a null exception. I tried setters and getters but nothing works. Have a look a the code and let me know. Perhaps the flow is wrong...

MyClass.class

The field with the type of the Enum class:



One of the action listener methods:



The setters and getters for the filed:



And of course, the switch that I try to apply and always returns a null exception:



Hope you guys can see what is wrong. Peace out!
4 years ago
Hi Piet,

Sorry for the long delay in my answer. I been busy implementing the code to my needs and I am pretty sure I made it. If you think the GA algorithm always is returning the shortest route. The one thing I don't fully understand is what is the population fitness and how does it actually influence the result. I noticed that the better result the higher is the population fitness. How come?

Many thank to you for your support, you helped a lot!
Cheers!
5 years ago
Yeah, I had run it on a different project and it is just fine. It returns a value from A ... A. It would be great to have it in java 7. I will try to implement it anyway, maybe I can substitute all the new words with some old ones. Let's see =)
5 years ago
Hey Piet,

Thank you for your quick reply. I had a look into the program and noticed the java8+ stuff. The thing is I have an Android project and its support not bigger than java 7, plus I don't know much of a java 8 and above. Could be there an alternative for streams and vars? I tried to add some streams in my project but they simply don't work because I have a minimum SDK 21 and is meant to be 24. =(
5 years ago