use of com.ibm.as400.access.IFSFile in project IBMiProgTool by vzupka.
the class ChangeLibraryList method getListOfLibraries.
/**
* Get list of all libraries whose names conform to the pattern defined in the input field
*
* @param libraryPattern
* @return
*/
protected String[] getListOfLibraries(String libraryPattern) {
libraryField = libraryPattern;
if (libraryField.isEmpty()) {
libraryPattern = "*";
}
libraryWildCard = libraryPattern.replace("*", ".*");
libraryWildCard = libraryWildCard.replace("?", ".");
IFSFile ifsFile = new IFSFile(remoteServer, "/QSYS.LIB");
if (ifsFile.getName().equals("QSYS.LIB")) {
try {
// Get list of subfiles/subdirectories
IFSFile[] ifsFiles2 = ifsFile.listFiles();
vectorLeft.removeAllElements();
for (IFSFile ifsFileLevel2 : ifsFiles2) {
if (ifsFileLevel2.toString().endsWith(".LIB")) {
String bareLibraryName = ifsFileLevel2.getName().substring(0, ifsFileLevel2.getName().indexOf("."));
if (bareLibraryName.matches(libraryWildCard)) {
vectorLeft.addElement(bareLibraryName);
}
}
}
// Fill the left list with library names
listLeft.setListData(vectorLeft);
// Set the left list as enabled for dragging from.
listLeft.setDragEnabled(true);
} catch (Exception exc) {
exc.printStackTrace();
}
}
String[] strArr = new String[vectorLeft.size()];
strArr = vectorLeft.toArray(strArr);
return strArr;
}
use of com.ibm.as400.access.IFSFile in project IBMiProgTool by vzupka.
the class SearchWindow method readIfsFile.
/**
* Read IFS file data into text area.
*
* @return
*/
protected JTextArea readIfsFile() {
try {
IFSFile ifsFile = new IFSFile(remoteServer, mainWindow.sourcePathString);
int attributeCCSID = ifsFile.getCCSID();
byte[] inputBuffer = new byte[100000];
byte[] workBuffer = new byte[100000];
try (IFSFileInputStream inputStream = new IFSFileInputStream(remoteServer, mainWindow.sourcePathString)) {
int bytesRead = inputStream.read(inputBuffer);
while (bytesRead != -1) {
for (int idx = 0; idx < bytesRead; idx++) {
// Copy input byte to output byte
workBuffer[idx] = inputBuffer[idx];
}
// Copy the printable part of the work array to a new buffer that will be written out.
byte[] bufferToWrite = new byte[bytesRead];
// Copy bytes from the work buffer to the new buffer
for (int indx = 0; indx < bytesRead; indx++) {
bufferToWrite[indx] = workBuffer[indx];
}
// Create object for conversion from bytes to characters
AS400Text textConverter = new AS400Text(bytesRead, attributeCCSID, remoteServer);
// Convert byte array buffer to text line
String textLine = (String) textConverter.toObject(bufferToWrite);
// Append the line to text area
textArea.append(textLine + NEW_LINE);
// Read next input buffer
bytesRead = inputStream.read(inputBuffer);
}
mainWindow.row = "Info: IFS file " + mainWindow.sourcePathString + " has CCSID " + attributeCCSID + ".";
mainWindow.msgVector.add(mainWindow.row);
mainWindow.showMessages(mainWindow.nodes);
}
} catch (Exception exc) {
exc.printStackTrace();
mainWindow.row = "Error: " + exc.toString();
mainWindow.msgVector.add(mainWindow.row);
mainWindow.showMessages(mainWindow.nodes);
}
// Remove message scroll listener (cancel scrolling to the last message)
mainWindow.scrollMessagePane.getVerticalScrollBar().removeAdjustmentListener(mainWindow.messageScrollPaneAdjustmentListenerMax);
return textArea;
}
use of com.ibm.as400.access.IFSFile in project IBMiProgTool by vzupka.
the class MainWindow method reloadRightSide.
/**
* Reload node structure in the right side of the window.
*/
protected void reloadRightSide() {
ifsFile = new IFSFile(remoteServer, rightPathString);
// Add IFS nodes (children) for the right tree in parallel background process
AddAS400Nodes an = new AddAS400Nodes(ifsFile, rightNode, this);
an.execute();
}
use of com.ibm.as400.access.IFSFile in project IBMiProgTool by vzupka.
the class MainWindow method expandRightTreeNode.
/**
* Expand right tree node after change.
*
* @param info
*/
protected void expandRightTreeNode(TransferHandler.TransferSupport info) {
IFSFile targetPath = new IFSFile(remoteServer, targetPathString);
// Target node
// -----------
targetNode = (DefaultMutableTreeNode) rightTree.getLastSelectedPathComponent();
// Add target node for inserted children
if (targetNode != null) {
// Add IFS nodes (children) for the right tree in parallel background process
AddAS400Nodes an = new AddAS400Nodes(targetPath, targetNode, this);
an.execute();
}
// Get coordinates of target node
TransferHandler.DropLocation dropLocation = info.getDropLocation();
double dropX = dropLocation.getDropPoint().getX();
double dropY = dropLocation.getDropPoint().getY();
// Get index from coordinates of the drop node
rightRow = rightTree.getRowForLocation((int) dropX, (int) dropY);
// Expand that node on that index
rightTree.expandRow(rightRow);
// Note that the children were added
rightTreeModel.nodeStructureChanged(targetNode);
}
Aggregations