/** * Returns whether this page's controls currently all contain valid values. * * @return <code>true</code> if all controls are valid, and <code>false</code> if at least one is * invalid */ protected boolean validatePage() { if (outputFolder == null || !outputFolder.exists()) { setErrorMessage( "No output folder is selected.\n" + "Please select a folder before starting the import wizard!"); return false; } if (editor.getStringValue().length() == 0) { // no error message as this is obvious to the user setErrorMessage(null); return false; } File inputFile = new File(editor.getStringValue()); if (!inputFile.exists()) { setErrorMessage("The file '" + inputFile.getName() + "' does not exist!"); return false; } if (inputFile.isDirectory()) { setErrorMessage("'" + inputFile.getName() + "' is a directory!"); return false; } if (getNewFolder().exists()) { setErrorMessage("The folder '" + getNewFolder().getFullPath() + "' already exists!"); return false; } setErrorMessage(null); return true; }
public InputStream getInitialContents() { try { return new FileInputStream(new File(editor.getStringValue())); } catch (FileNotFoundException e) { return null; } }
void updateKeystoreCertInfo() { info = new KeystoreCertificateInfo( keyStore.getStringValue(), alias.getText(), storekey.getText(), passkey.getText(), true); dirty = false; }
protected IFolder getNewFolder() { if (outputFolder != null && outputFolder.exists()) { String[] pathSegments = StringHelper.withoutExtension((new File(editor.getStringValue())).getName()).split("-"); IFolder importFolder = outputFolder; for (String pathSegment : pathSegments) { importFolder = importFolder.getFolder(convertToJavaCompliantName(pathSegment)); } folderName = importFolder.getName(); return importFolder; } return null; }
public void deleteNewFolder() { if (outputFolder != null && outputFolder.exists()) { String[] pathSegments = StringHelper.withoutExtension((new File(editor.getStringValue())).getName()).split("-"); IFolder importFolder = outputFolder; for (String pathSegment : pathSegments) { importFolder = importFolder.getFolder(convertToJavaCompliantName(pathSegment)); } try { while (importFolder != outputFolder && importFolder.getParent() instanceof IFolder) { if (importFolder.members().length == 0) { importFolder.delete(false, null); } importFolder = (IFolder) importFolder.getParent(); } } catch (CoreException e) { OfsCore.getDefault() .logWarning("Could not delete empty import folder '" + importFolder + "'", e); e.printStackTrace(); } } }
public String getSelectedFileName() { File file = new File(editor.getStringValue()); String fileName = file.getName(); return fileName.substring(0, fileName.lastIndexOf(".")); }