Java JFileChooser with Filter to supposedly display ONLY directories fail to show just directories
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Your code works for me. My SSCCE: import java.io.File;
import javax.swing.JFileChooser;
public class ShowDirectoriesOnly {
public static void main(String[] args) {
JFileChooser fileChooser = new JFileChooser( "." );
fileChooser.setControlButtonsAreShown( false );
fileChooser.setFileFilter( new FolderFilter() );
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fileChooser.showOpenDialog(null);
}
private static class FolderFilter extends javax.swing.filechooser.FileFilter {
@Override
public boolean accept( File file ) {
return file.isDirectory();
}
@Override
public String getDescription() {
return "We only take directories";
}
}
}
|
How could I configure Apache to display file names as directories instead?
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , The best way to approach mod_rewrite is to create a test server/virtual host and slowly build your configuration. Also, try to make your initial rules very simple, so you can exactly understand what every rule does. This configuration can help you start with your process. The last rule is what you need to map your CreateAccount/ path to CreateAccount.php script. <IfModule mod_rewrite.c>
RewriteEngine On
# You can use this only inside of the Directory directive or in the .htaccess file.
RewriteBase /
# http://www.example.com/page.html to redirect to http://www.example.com/page.php
RewriteRule ^(.*).html /$1.php [L]
# http://www.example.com/mypath/page.html to redirect to http://www.example.com/mypath/page.php
RewriteRule ^mypath/(.*).html /mypath/$1.php [L]
# http://www.example.com/CreateAccount/ to redirect to http://www.example.com/CreateAccount.php
RewriteRule ^(.*)/ /$1.php [L]
</IfModule>
|
Display file properties dialog for files in different directories
Date : March 29 2020, 07:55 AM
With these it helps IShellFolder::GetUIObjectOf() only works with single-level PIDLs that are relative to the IShellFolder being queried. This is clearly stated in the GetUIObjectOf() documentation: int main()
{
CoInitialize(NULL);
LPOLESTR pszFile = OLESTR("c:\\Windows\\notepad.exe");
LPOLESTR pszFile2 = OLESTR("c:\\Windows\\System32\\notepad.exe");
LPITEMIDLIST pidl;
LPITEMIDLIST pidl2;
HRESULT hr;
IShellFolder* pDesktop;
IDataObject *pDataObject;
hr = SHGetDesktopFolder(&pDesktop);
if (FAILED(hr))
{
CoUninitialize();
return 0;
}
hr = pDesktop->ParseDisplayName(HWND_DESKTOP, NULL, pszFile, NULL, &pidl, NULL);
if (FAILED(hr)) {
pDesktop->Release();
CoUninitialize();
return 0;
}
hr = pDesktop->ParseDisplayName(HWND_DESKTOP, NULL, pszFile2, NULL, &pidl2, NULL);
if (FAILED(hr)) {
SHFree(pidl);
pDesktop->Release();
CoUninitialize();
return 0;
}
LPCITEMIDLIST list[] = {pidl, pidl2};
hr = pDesktop->GetUIObjectOf(HWND_DESKTOP, 2, (LPCITEMIDLIST *)list, IID_IDataObject, NULL, (void **)&pDataObject);
// alternatively, you can also use SHCreateDataObject() or CIDLData_CreateFromIDArray() to create the IDataObject
pDesktop->Release();
SHFree(pidl);
SHFree(pidl2);
if (SUCCEEDED(hr)) {
hr = SHMultiFileProperties(pDataObject, 0);
pDataObject->Release();
if (SUCCEEDED(hr)) {
MessageBox(0, _T("Dummy message box"), 0, 0);
Sleep(10000); // Give the system time to show the dialog before exiting
}
}
CoUninitialize();
return 0;
}
|
Bash shell - count and display the list of directories and sub-directories in chronologicall order
Tag : linux , By : Ansari
Date : March 29 2020, 07:55 AM
Hope that helps you could try using the find command or tree -d -t -f this a temp structure which i have created(ls -R = list recursively) ~/temp$ ls -R
.:
dir1/ dir2/ dir3/ file1
./dir1:
catalog1
./dir2:
./dir3:
$ ls -R temp
temp:
dir1/ dir2/ dir3/ file1
temp/dir1:
dir3/ dir4/
temp/dir1/dir3:
temp/dir1/dir4:
temp/dir2:
dir/ dir4/ dir5/ dir6/
temp/dir2/dir:
newdir/
temp/dir2/dir/newdir:
temp/dir2/dir4:
temp/dir2/dir5:
temp/dir2/dir6:
temp/dir3:
#!/bin/bash
declare front_element="./temp"
#dir to start with
declare -a q=($(find "$front_element" -maxdepth 1 -type d -not -path "$front_element" -printf '%T@ %p\n' | sort | awk '{print $2}'))
#initial queue population
declare -a temp_arr
if [[ ${#q[@]} -eq 0 ]]; then
printf "%s%s contains %d child directories(last modified time sort): \n" "----->" "$front_element" "${#q[@]}"
else
printf "%s%s contains the following %d child directories(last modified time sort): \n" "----->" "$front_element" "${#q[@]}"
fi
printf "\t%s\n" "${q[@]}"
while [[ ${#q[@]} -ne 0 ]]
do
front_element="${q[0]}"
#Queue fetching front element
#echo "$front_element is front_element"
q=("${q[@]:1}")
#actual queue dequeue operation=>reduction in size
temp_arr=($(find "$front_element" -maxdepth 1 -type d -not -path "$front_element" -printf '%T@ %p\n' | sort | awk '{print $2}'))
#excluding self during find using -not -path self, %Tk=last modified time printed in k format(here used @=>time in seconds since UTC/Unix Epoch Jan 1, 1970 midnight along with fractional part), %p=found path, sort=>uses last modified time to sort and it sorts alphabetically if same last modified time for >=2 directories(highly unlikely as it has fractional part too)
if [[ ${#temp_arr[@]} -eq 0 ]]; then
printf "%s%s contains %d child directories. \n" "----->" "$front_element" "${#temp_arr[@]}"
else
printf "%s%s contains the following %d child directories(last modified time sorted): \n" "----->" "$front_element" "${#temp_arr[@]}"
fi
#displaying the count as well
if [[ ${#temp_arr[@]} -gt 0 ]]
then
printf "\t%s\n" "${temp_arr[@]}"
echo
for element in "${temp_arr[@]}"
do
q+=("$element")
done
fi
#appending newly found stuff to the current queue for further processing
#echo "${q[@]} is q at end of iteration"
#echo "${temp_arr[@]} is temp_arr at end of iteration"
done
$ ./script.bash
----->./temp contains the following 3 child directories(last modified time sort):
./temp/dir3
./temp/dir1
./temp/dir2
----->./temp/dir3 contains 0 child directories.
----->./temp/dir1 contains the following 2 child directories(last modified time sorted):
./temp/dir1/dir3
./temp/dir1/dir4
----->./temp/dir2 contains the following 4 child directories(last modified time sorted):
./temp/dir2/dir4
./temp/dir2/dir5
./temp/dir2/dir6
./temp/dir2/dir
----->./temp/dir1/dir3 contains 0 child directories.
----->./temp/dir1/dir4 contains 0 child directories.
----->./temp/dir2/dir4 contains 0 child directories.
----->./temp/dir2/dir5 contains 0 child directories.
----->./temp/dir2/dir6 contains 0 child directories.
----->./temp/dir2/dir contains the following 1 child directories(last modified time sorted):
./temp/dir2/dir/newdir
----->./temp/dir2/dir/newdir contains 0 child directories.
|
Require to display limited number of file names from directories -php
Date : March 29 2020, 07:55 AM
|