How to add intellisense to a search line in java swing - java

This is my first time with intellisense so please go easy on me :)
I'm using Java swing for building a search engine for viewing XML files .
At the moment the XML file is uploaded and searched successfully , however I still
would like to add the intellisense element to the project .
It's very hard to be specific since the code is pretty big , then I'll do my best to be
as specific as I could .
Here is a visual picture of the XML search engine :
Now , after the user uploaded the XML file (using the open button on the left)
he enters a query in the **current path:* box . Each part of the query is separated via / , hence what I want is to give to the user my options when he hits / , which they are :
String[] axesTypes = {"child::", "attribute::", "descendant::",
"descendant-or-self::", "slef::", "parent::",
"following-sibling::", "preceding-sibling::",
"ancestor-or-self::", "ancestor::", "following::",
"preceding::" ,"preceding::", "namespace::", "node()"};
I'd appreciate if someone can give an explanation regarding how to add that element to my project .
If you need me to post the code - please say so , and I would .
Regards

Related

ESAPI not passing file validation

I am working with ESAPI to try and validate windows directory paths. For some reason, the part of my directory path named \14\ is getting converted into a CRLF. The error I am receiving is below, what am I not understanding correctly? I feel like my regex should be working.
WARN IntrusionDetector [SECURITY FAILURE Anonymous:null#unknown -> /project-test/IntrusionDetector] Invalid input: context=directoryPath, type(DirectoryName)=^[a-zA-Z0-9:/\\!##$%^&{}\[\]()_+\-=,.~'` ]{1,255}$, input=C:\UsersTESTUS~1AppDataLocalTempTestCase8002TempWorkSpace, orig=C:\Users\TESTUS~1\AppData\Local\Temp\14\TestCase8002TempWorkSpace
As you can see, I am using the regex:
^[a-zA-Z0-9:/\!##$%^&{}[]()_+-=,.~'` ]$
My input is:
C:\Users\TESTUS~1\AppData\Local\Temp\14\TestCase8002TempWorkSpace
Ouput, after ESAPI does canonicalization and validation:
C:\UsersTESTUS~1AppDataLocalTempTestCase8002TempWorkSpace
Here is the line of code that causes me to receive the error;
String validatedSourcePath = ESAPI.validator().getValidInput("directoryUnzip", directory, "DirectoryName", 255, false);
File validFile = new File(validatedSourcePath);
#C.Williams: I was about 30 minutes into writing up a detailed reply in an editor and accidentally excited my editor window. I'm too ticked off at my stupidity of not saving it to write it again, especially since I was only about 75% done.
However, if you want to email me I can arrange to talk to you via Google Hangouts or Signal to tell you want your problem is and how you can fix it. But it's long and complicated and partially related to a bug the ESAPI team just fixed but is not in any official release yet. But I am not going to take another 45 minutes or more trying to reply with any written text. My email address should be easy enough to find. Just google for my name and ESAPI. I am one of the project co-leaders on ESAPI.
-kevin wall

Use information from view page source in automated test

Im trying to get some information from my page source. I run my automated tests on every release but want to avoid updating the release number manually as im trying to integrate my tests in CI and was hoping i could pull the tag from the page source.
All i know that works here is Drivers.getDriver.getPageSource but have no idea how to pull information.
The main issue im having is that the version is in 2 sections:
< meta http-equiv="version" content="1.4.39" >
I want to be able to take the 1.4.39 out of the page source and add to string
This surely is possible, you just had to have locator for this element.
For example if I take it's cssSelector as:
meta[http-equiv*='version']
We can easily do this:
driver.findElement(By.cssSelector("meta[http-equiv*='version']")).getAttribute("content")
This will return you 1.4.39 as String value.
Hope this helped.

Forge modding (can't get a texture on item) Minecraft 1.9.4

Hi can somebody help me fix this.
My texture on item is not loading.
I'm modding in eclipse on minecraft 1.9.4
Here is a github page with source code :
Github page
Here is a gist with a console log :
Console log
I hope somebody knows more than me :)
You have a few problems with your code:
Your file is named ItemSlome, it would only search for itemslome, because (Model)ResourceLocations will be turned to lower-case.
The ModelResourceLocation you created is for slome not itemslome.
Your file is in the "ktm" domain, but you did not provide this to the ModelResourceLocation causing it to search in the "minecraft" domain.
Solutions:
Make the model file's name all lower-case
Make the model file's name match your code
Prepend the model name by your domain "ktm:" the ":" is the seperator for the domain part and the resource part or use a ResourceLocation instead of the String.
Additional Hints:
You may want to use ModelLoader.setCustomModelResourceLocation(...) to register your ModelResourceLocation.
Examples for a correct ModelResourceLocation:
new ModelResourceLocation("ktm:slome", "inventory"))
new ModelResourceLocation(new ResourceLocation("ktm","slome"),"inventory")
Both of the above examples will lead to the model being searched at resource_root/ktm/models/item/slome.json
This is how you set the texture of a block you have to put a colon after The Mod Name instead of comma
YourItemName = new Item().setUnlocalizedName("YourItemName")
.setTextureName("ModName:PutTextureNameHere")
.setCreativeTab(TheTabYouWantItToBeIn);

Programatically embed a video in a slideshow using Apache Open Office API

I want to create a plugin that adds a video on the current slide in an open instance of Open Office Impress by specifying the location of the video automatically. I have successfully added shapes to the slide. But I cannot find a way to embed a video.
Using the .uno:InsertAVMedia I can take user input to choose a file and it works. How do I want to specify the location of the file programmatically?
CONCLUSION:
This is not supported by the API. Images and audio can be inserted without user intervention but videos cannot be done this way. Hope this feature is released in subsequent versions.
You requested information about an extension, even though the code you are using is quite different, using a file stream reader and POI.
If you really do want to develop an extension, then start with one of the Java samples. An example that uses Impress is https://wiki.openoffice.org/wiki/File:SDraw.zip.
Inserting videos into an Impress presentation can be difficult. First be sure you can get it to work manually. The most obvious way to do that seems to be Insert -> Media -> Audio or Video. However many people use links to files instead of actually embedding the file. See also https://ask.libreoffice.org/en/question/1898/how-to-embed-video-into-impress-presentation/.
If embedding is working for your needs and you want to automate the embedding by using an extension (which seems to be what your question is asking), then there is a dispatcher method called InsertAVMedia that does this.
I do not know offhand what the parameters are for the call. See https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=61127 for how to look up parameters for dispatcher calls.
EDIT
Here is some Basic code that inserts a video.
sub insert_video
dim document as object
dim dispatcher as object
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(document, ".uno:InsertAVMedia", "", 0, Array())
end sub
From looking at InsertAVMedia in sfx.sdi, it seems that this call does not take any parameters.
EDIT 2
Sorry but InsertVideo and InsertImage do not take parameters either. From svx.sdi it looks like the following calls take parameters of some sort: InsertGalleryPic, InsertGraphic, InsertObject, InsertPlugin, AVMediaToolBox.
However according to https://wiki.openoffice.org/wiki/Documentation/OOoAuthors_User_Manual/Getting_Started/Sometimes_the_macro_recorder_fails, it is not possible to specify a file for InsertObject. That documentation also mentions that you never know what will work until you try it.
InsertGraphic takes a FileName parameter, so I would think that should work.
It is possible to add an XPlayer on the current slide. It looks like this will allow you to play a video, and you can specify the file's URL automatically.
Here is an example using createPlayer: https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=57699.
EDIT:
This Basic code works on my system. To play the video, simply call the routine.
sub play_video
If Video_flag = 0 Then
video =converttoURL( _
"C:\Users\JimStandard\Downloads\H264_test1_Talkinghead_avi_480x360.avi")
Video_flag = 1
'for windows:
oManager = CreateUnoService("com.sun.star.media.Manager_DirectX")
' for Linux
' oManager = CreateUnoService("com.sun.star.media.Manager_GStreamer")
oPlayer = oManager.createPlayer( video )
' oPlayer.CreatePlayerwindow(array()) ' crashes?
'oPlayer.setRate(1.1)
oPlayer.setPlaybackLoop(False)
oPlayer.setMediaTime(0.0)
oPlayer.setVolumeDB(GetSoundVolume())
oPlayer.start() ' Lecture
Player_flag = 1
Else
oPlayer.start() ' Lecture
Player_flag = 1
End If
End Sub

CRF++: Yet Another CRF Tool Kit

When I use CRF++ toolkit for the first time. I have installed it and when I run the crflearn command I'am getting this message :
CRF++: Yet Another CRF Tool Kit Copyright (C) 2005-2013 Taku Kudo, All rights reserved. encoder.cpp(340) [feature_index.open(templfile, trainfile)] feature_index.cpp(135) [ifs] open failed: template_file
Can anyone help me?
The package is pretty well documented here
Can you give the full command you tried to use?
The pattern is crf_learn -t [template_file] [data_file_in_the_right_format]
The package comes with an example template file, here's the head of mine:
U00:%x[-5,0]
U01:%x[-4,0]
U02:%x[-3,0]
U03:%x[-2,0]
U04:%x[-1,0]
U05:%x[0,0]
The data needs to be in a tab delimited format with each data point represented by a row, each column is the feature value for that row and the final column is your gold standard label.
Does that help?
You put wrong file path for template featurefile and model. So, put these files inside CRF-PP folder and fire the crf_learn command. Hope this will solve your issue.

Categories

Resources