IContainer parentResource; if (valueFromDict != null) { switch (valueFromDict.intValue()) { case PLUGIN_NAME : expandedValue = WOLipsPlugin.getDefault().getDescriptor().getLabel(); break; case CLASS : expandedValue = fileNameWithoutExtension; break; case DATE : expandedValue = (new java.util.Date()).toString(); break; case PROJECT_NAME : parentResource = fileToCreate.getParent(); if (parentResource instanceof IProject) { expandedValue = ((IProject) parentResource).getName(); } else if (parentResource instanceof IFolder) { expandedValue = ((IFolder) parentResource).getName(); } break; case PACKAGE_NAME : if (fileToCreate.getProjectRelativePath().segmentCount() > 2) {   parentResource = fileToCreate.getParent(); StringBuffer packageNameBuffer = new StringBuffer("package "); IPath folderPath = ((IFolder) parentResource).getProjectRelativePath(); for (int i = 1; i < folderPath.segmentCount(); i++) { packageNameBuffer.append(folderPath.segment(i)); packageNameBuffer.append("."); } packageNameBuffer.deleteCharAt( packageNameBuffer.length() - 1); packageNameBuffer.append(";"); expandedValue = packageNameBuffer.toString(); } else {  expandedValue = ""; } break; case ADAPTOR_NAME : if (variableInfo != null && variableInfo.get(variableToExpand) != null) { expandedValue = (String) variableInfo.get(variableToExpand); } break; case BUILD_DIR :  IJavaProject actualJavaProject = JavaCore.create(fileToCreate.getProject()); IPath outputLocation; try { outputLocation = actualJavaProject.getOutputLocation(); } catch (JavaModelException e) { break; } expandedValue = outputLocation .makeRelative() .removeFirstSegments(1) .toString(); for (int i = 0; i < fileToCreate .getProjectRelativePath() .segmentCount() - 1; i++) { expandedValue = "../" + expandedValue; } break; case NEXT_ROOT : expandedValue = Environment.nextRoot(); break; }
switch (valueFromDict.intValue()) { case PLUGIN_NAME : expandedValue = WOLipsPlugin.getDefault().getDescriptor().getLabel(); break; case CLASS : expandedValue = fileNameWithoutExtension; break; case DATE : expandedValue = (new java.util.Date()).toString(); break; case PROJECT_NAME : expandedValue = this.getExpandedValueForProjectName(expandedValue); break; case PACKAGE_NAME : expandedValue = this.getExpandedValueForPackageName(expandedValue); break; case ADAPTOR_NAME : if (variableInfo != null && variableInfo.get(variableToExpand) != null) { expandedValue = (String) variableInfo.get(variableToExpand); } break; case BUILD_DIR : expandedValue = this.getExpandedValueForBuildDir(expandedValue); break; case NEXT_ROOT : expandedValue = Environment.nextRoot(); break;
	private String expandVariable(String variableToExpand) {		Integer valueFromDict =			(Integer) getKeyToIntegerDict().get(variableToExpand);		// default value		String expandedValue = variableToExpand;		IContainer parentResource;		if (valueFromDict != null) {			switch (valueFromDict.intValue()) {				case PLUGIN_NAME :					expandedValue =						WOLipsPlugin.getDefault().getDescriptor().getLabel();					break;				case CLASS :					expandedValue = fileNameWithoutExtension;					break;				case DATE :					expandedValue = (new java.util.Date()).toString();					break;				case PROJECT_NAME :					parentResource = fileToCreate.getParent();					if (parentResource instanceof IProject) {						expandedValue = ((IProject) parentResource).getName();					} else if (parentResource instanceof IFolder) {						expandedValue = ((IFolder) parentResource).getName();					}					break;				case PACKAGE_NAME :					if (fileToCreate.getProjectRelativePath().segmentCount()						> 2) {						// source folders are non hierachical -> segment[0]						// if file is at least in segment[1] it must be a package						parentResource = fileToCreate.getParent();						StringBuffer packageNameBuffer =							new StringBuffer("package ");						IPath folderPath =							((IFolder) parentResource).getProjectRelativePath();						for (int i = 1; i < folderPath.segmentCount(); i++) {							packageNameBuffer.append(folderPath.segment(i));							packageNameBuffer.append(".");						}						packageNameBuffer.deleteCharAt(							packageNameBuffer.length() - 1);						packageNameBuffer.append(";");						expandedValue = packageNameBuffer.toString();					} else {						// no package declaration needed						expandedValue = "";					}					break;				case ADAPTOR_NAME :					if (variableInfo != null						&& variableInfo.get(variableToExpand) != null) {						expandedValue =							(String) variableInfo.get(variableToExpand);					}					break;				case BUILD_DIR :					// relativ path to output location					IJavaProject actualJavaProject =						JavaCore.create(fileToCreate.getProject());					IPath outputLocation;					try {						outputLocation = actualJavaProject.getOutputLocation();					} catch (JavaModelException e) {						break;					}					expandedValue =						outputLocation							.makeRelative()							.removeFirstSegments(1)							.toString();					for (int i = 0;						i							< fileToCreate								.getProjectRelativePath()								.segmentCount()								- 1;						i++) {						expandedValue = "../" + expandedValue;					}					break;				case NEXT_ROOT :					expandedValue = Environment.nextRoot();					break;			}		}		return expandedValue;	}