I want to restrict JavaFX File chooser to its initial directory.
I've seen that it's possible in Swing (How do I restrict JFileChooser to a directory?) but I could not find anything similar in java fx.
Is there a way to achieve this?
This probably is a environment based window, and until java Specifies a Class for that (Which I feel it does not), you really can't do anything about it.
But you could always let the user choose the directory and then check the directory and if it does not match your criteria, you could set the value to null and ask the user to input it again
File f = fileChooser.showOpenDialog(primaryStage);
if(f.getAbsolutePath().matches("regex")){
//Do Something
}
Here regex would be replaced with somethinglike this
[.+]//yourPath
If you want to know more about regex, Visit here
Related
I'm writing a piece of code to simulate some stuff of diagnostic.
I've created with CANalyzer, a panel with tons of information that need to be shown using a picklist (called combobox)
What I want to do is to create a giant array of that struct that need to be selected using the SPN combobox (the picklist) , and the other parameters of the struct/object need to populate the other elements of the panel.
Is this possible without doing a tons of SysSetVariableInt or SysSetVariableString for each element?
Before I was doing this stuff using another technique, I parse the file with all the information that are stored in a giant matrix, then I use the method "on sysvar update" on the variable associated to the SPN picklist, to get the index of that, so I search for that index in the matrix, then I use the SysSetVariableInt or others, to set the values to the elements in the panel.
To populate the picklist I've found a pretty nice method "sysSetVariableDescriptionForValue" that helps to add elements, but the problem with this method, is that if you want to change elements, you can just overwrite, and not change all...so, if in a next iteration you push less element in the picklist, you will see also the old ones.
With "sysSetVariableDescriptionForValue" you basically are writing via code, the value table of that sysvariable, and is not possible (according to Vector), be flushed, on runtime... :/
I would love to do this thing using another approach, maybe with the struct is possible...i really don't know.
Any help will be very appreciated!
Regards!
TLDR; build a tool to create a .sysvar file from a structured input (comma-separated for instance), run it, get the .sysvar file and link it to the CANalyzer configuration.
I once had to create the entire testing interface with some components of the software. We didn't have a structured release procedure, and the test environment was rebuilt every time from scratch based on the new internal software interfaces. I too had to add hundreds of variables.
My solution was to generate .sysvar files programatically outside CANalyzer. Links to the .sysvar files are symbolic in the CANalyzer configuration, meaning if a file by the right name is in the right location, that file is going to be loaded.
What I want to do is to create a giant array of that struct that need
to be selected using the SPN combobox (the picklist) , and the other
parameters of the struct/object need to populate the other elements
of the panel. Is this possible without doing a tons of
SysSetVariableInt or SysSetVariableString for each element?
Create an external script to generate the .sysvar file. In the end it is just an xml file, you may study the structure of a demo one you save. Then, import that file in the CANalyzer config. You may need to close/re-open the configuration in case the .sysvar file changes.
PROs: no need to write a complicated CAPL script and update it every time a variable changes.
CONs: you must have a source for all the information, even a simple excel sheet, with all the description and such, and you have to create a tool that accepts the input file (let's assume a .csv file) and turns it into a .xml file with .sysvar extension instead.
Suppose I have a non-qt object. For example, the QT static-only log handler. How does one cause this file handler to know where to go to look for the current configuration file without, say, hard-coding the application name, organization etc. into the static log-handler function?
I have tried defining a global pointer to the configuration that gets initialized during a startup phase, but this turns out to be a hairy problem to solve during the linking phase. Is there some particular "only-way-is-the-best-way" solution?
(New to QT; if there is an "accepted" or "intended" approach, I would like to take that)
May be create global singleton class?
Or set QSettings::setDefaultFormat() to ini near your binary?
Is there a way to programmatically create folders? There was a way to do it in lotus script - that method also was not documented in designer help. I want to get a document collection and then put the whole collection into a folder. I can see in the documentation that this will create the folder - I want to add columns to the folder. I suppose at worst I can open the folder after it has been created from the "put" command.
You can use ViewEntryCollection.PutAllInFolder method https://www.ibm.com/support/knowledgecenter/en/SSVRGU_9.0.1/basic/H_PUTALLINFOLDER_METHOD_VEC_JAVA.html
The folder will be created from the view/folder flagged as "Default for new views/folders" property. To change its design, you can use createColumn method https://www.ibm.com/support/knowledgecenter/SSVRGU_9.0.0/com.ibm.designer.domino.main.doc/H_CREATECOLUMN_METHOD_VIEW_JAVA.html
If you want to modify the design by adding columns, it will need to run with a ID that has at least Designer access to the database. ODA has a design API that can be used to create design elements via DXL. I've used it to create views, but folders should work the same.
If you don't need to modify the design, you can create a Shared Private on First Use folder by running as the user and calling getView(). I don't think that needs designer access, but it's worth double-checking.
Note: the ODA methods haven't been tested from SSJS. If it works, you're lucky, but the focus is Java.
I just want to ask if there's a way to retrieve the root directory of a Symfony Application ANYHWERE?
What I mean by anywhere is, in any file of my App.
I've searched everywhere and all I get is this:
$this->get('kernel')->getRootDir();
Which of course works! But I can't use it in my custom classes. I need to get the root directory in one of my custom classes.
I've already read answers about DependencyInjection/Service and other stuff, but I think it's too complex/overkill to implement those just to solve my current problem.
I just want the root directory of my app, period. Is there any other way?
The simplest way I can think of is to define a constant in your app.php file, like this:
define("ROOTDIR", $kernel->getRootDir());
so you can then use this constant anywhere. Compared to this, a static method is overkill, too.
I reviewed my answer. Indeed, it will not fit your need. Anyway, if you don't want to use dependency injection to achieve this goal because you have static methods, where do you call these static methods? In a controller? In a command? In another service? If you don't want to instanciate your class because you don't want objects with their own data, you have 2 options:
Get the root directory outside your class, and use it as a parameter for your static methods.
If your class uses static methods that means your class behave as a helper class, it is just a tool (converter, exporter, renderer...etc). So I assume that you placed all your helper classes in one directory. In this case you can create a enum class which defines constant like root dir, web dir giving the absolute paths.
I'm creating a list of permission settings for an OrganizationalItemData object with the Core Service and am looking for help confirming when to explicitly set permissions in the CME.
Question
Given an organizational item and knowing its shared, localized, and permissions inheritance settings, when do we need to explicitly set permissions for it (in the CME under Properties > Security)?
API Details
Given OrganizationalItemData orgItem I can check the following (with details from the documentation).
IsShared
Gets or sets whether the item is shared in the current context Publication.
IsLocalized
Gets or sets whether the item is localized in the current context Publication.
IsPermissionsInheritanceRoot
true if permissions are specified for item itself; otherwise, false, if item inherits permissions from the parent item.
Example Code
I can use the Core Service to check permission settings in a given CMS. For example:
var CreatedHere = !orgItem.BluePrintInfo.IsShared.GetValueOrDefault();
var IsLocalized = orgItem.BluePrintInfo.IsLocalized.GetValueOrDefault();
var PermissionsFromParent = !orgItem.IsPermissionsInheritanceRoot.GetValueOrDefault();
I'd like to output the permissions for a given Organizational Item, but also instructions for when the CMS administrator actually needs to set properties in its publication. For example I could use a script against CMS Test to show what CMS Production might need.
Scenarios
Here's the truth of it (I think).
Shared Local(ized) PermissionsRoot Set here?
No No No No, set in parent in this Publication.
No No Yes Yes, set in this "local" item.
No Yes No Not possible. Can't localize non-shared item.
No Yes Yes Not possible. Can't localize non-shared item.
Yes No No No, set in parent item in higher Publication.
Yes No Yes No, set in this item but in a higher publication.
Yes Yes No No, set in parent item in this Publication.
Yes Yes Yes Yes
I might be wrong in my understanding of these options, but so far it seems we only need to explicitly set permissions for two scenarios:
For a non-shared (local) item that is a permissions root (Inherit Security Settings from Parent unchecked)
For a shared, localized item that is a permissions root.
Do I have the right scenarios and/or am I missing something in the 2^3 scenarios above?
I think you have it about right Alvin.
First of all, the only place you can ever have permissions is at an inheritance root.
Secondly, normal blueprinting rules apply.
I used to draw this as a diagram with a zig-zag arrow, showing the search for permissions:
(Imagine you're a folder trying to figure out stuff)
Am I a local inheritance root? No - keep on looking
OK - so BluePrinting applies, so maybe I'm a shared folder and I'm an inheritance root via bluePrinting? Nope? OK - keep on looking,
So what about that folder above me in the tree? Are there any permissions there? Is it a local inheritance root? Is it an inheritance root by way of BluePrinting? Nope - keep on looking
And so on all the way to the top
So looking at your table: Anything where "Permissions root" is false, can't have it's own permissions, so correctly you have either no or not possible for each of these.
For org items that are inheritance roots, the next question is are they local/localized or are they shared. Again you seem to have got this correct.
There's only one point of attention that I'd mention, and that is that perhaps "Localized" is the wrong name for your second column. I'd say "local" instead. An item is local if it is not shared, and this can be because it's been localised from a shared item in another publication, or because it's been created locally in this publication. I think you realise that any scripted or programmed approach you take needs to accommodate both scenarios.