X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/wizards/NewTypeWizardPage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/wizards/NewTypeWizardPage.java index a12516f..8105380 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/wizards/NewTypeWizardPage.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/wizards/NewTypeWizardPage.java @@ -27,9 +27,9 @@ import net.sourceforge.phpdt.core.compiler.ITerminalSymbols; import net.sourceforge.phpdt.core.compiler.InvalidInputException; import net.sourceforge.phpdt.externaltools.internal.ui.StatusInfo; import net.sourceforge.phpdt.internal.corext.codemanipulation.StubUtility; -import net.sourceforge.phpdt.internal.corext.template.Template; -import net.sourceforge.phpdt.internal.corext.template.Templates; import net.sourceforge.phpdt.internal.corext.template.php.JavaContext; +import net.sourceforge.phpdt.internal.corext.template.php.Templates; +import net.sourceforge.phpdt.internal.corext.util.JavaModelUtil; import net.sourceforge.phpdt.internal.ui.PHPUiImages; import net.sourceforge.phpdt.internal.ui.util.SWTUtil; import net.sourceforge.phpdt.internal.ui.wizards.NewWizardMessages; @@ -45,10 +45,9 @@ import net.sourceforge.phpdt.internal.ui.wizards.dialogfields.Separator; import net.sourceforge.phpdt.internal.ui.wizards.dialogfields.StringButtonDialogField; import net.sourceforge.phpdt.internal.ui.wizards.dialogfields.StringButtonStatusDialogField; import net.sourceforge.phpdt.internal.ui.wizards.dialogfields.StringDialogField; -import net.sourceforge.phpdt.ui.JavaUI; +import net.sourceforge.phpdt.ui.CodeGeneration; import net.sourceforge.phpdt.ui.PreferenceConstants; import net.sourceforge.phpeclipse.PHPeclipsePlugin; -import net.sourceforge.phpeclipse.phpeditor.EditorUtility; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; @@ -56,6 +55,9 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.templates.Template; +import org.eclipse.jface.text.templates.TemplateException; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; @@ -76,8 +78,8 @@ import org.eclipse.swt.widgets.Control; * example usage of NewTypeWizardPage. *

* - * @see org.eclipse.jdt.ui.wizards.NewClassWizardPage - * @see org.eclipse.jdt.ui.wizards.NewInterfaceWizardPage + * @see net.sourceforge.phpdt.ui.wizards.NewClassWizardPage + * @see net.sourceforge.phpdt.ui.wizards.NewInterfaceWizardPage * * @since 2.0 */ @@ -406,7 +408,7 @@ public abstract class NewTypeWizardPage extends NewContainerWizardPage { Button button = fEnclosingTypeDialogField.getChangeControl(composite); gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - gd.heightHint = SWTUtil.getButtonHeigthHint(button); + gd.heightHint = SWTUtil.getButtonHeightHint(button); gd.widthHint = SWTUtil.getButtonWidthHint(button); button.setLayoutData(gd); } @@ -599,7 +601,7 @@ public abstract class NewTypeWizardPage extends NewContainerWizardPage { // -------- update message ---------------- /* - * @see org.eclipse.jdt.ui.wizards.NewContainerWizardPage#handleFieldChanged(String) + * @see net.sourceforge.phpdt.ui.wizards.NewContainerWizardPage#handleFieldChanged(String) */ protected void handleFieldChanged(String fieldName) { super.handleFieldChanged(fieldName); @@ -1322,17 +1324,17 @@ public abstract class NewTypeWizardPage extends NewContainerWizardPage { // if (!isInnerClass) { lineDelimiter = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ // -// ICompilationUnit parentCU = pack.createCompilationUnit(clName + ".php", "", false, new SubProgressMonitor(monitor, 2)); //$NON-NLS-1$ //$NON-NLS-2$ +// ICompilationUnit parentCU = pack.createCompilationUnit(clName + ".php", "", false, new SubProgressMonitor(monitor, 2)); //$NON-NLS-1$ //$NON-NLS-2$ // createdWorkingCopy = (ICompilationUnit) parentCU.getSharedWorkingCopy(null, JavaUI.getBufferFactory(), null); // // imports = new ImportsStructure(createdWorkingCopy, prefOrder, threshold, false); // // add an import that will be removed again. Having this import solves 14661 // imports.addImport(pack.getElementName(), getTypeName()); // -// String typeContent = constructTypeStub(new ImportsManager(imports), lineDelimiter); -// + String typeContent = constructTypeStub(lineDelimiter);//new ImportsManager(imports), lineDelimiter); + // String cuContent = constructCUContent(parentCU, typeContent, lineDelimiter); -// + // createdWorkingCopy.getBuffer().setContents(cuContent); // createdType = createdWorkingCopy.getType(clName); @@ -1494,25 +1496,25 @@ public abstract class NewTypeWizardPage extends NewContainerWizardPage { /* * Called from createType to construct the source for this type */ - // private String constructTypeStub(ImportsManager imports, String lineDelimiter) { - // StringBuffer buf= new StringBuffer(); - // - // int modifiers= getModifiers(); - // buf.append(Flags.toString(modifiers)); - // if (modifiers != 0) { - // buf.append(' '); - // } - // buf.append(fIsClass ? "class " : "interface "); //$NON-NLS-2$ //$NON-NLS-1$ - // buf.append(getTypeName()); - // writeSuperClass(buf, imports); - // writeSuperInterfaces(buf, imports); - // buf.append('{'); - // buf.append(lineDelimiter); - // buf.append(lineDelimiter); - // buf.append('}'); - // buf.append(lineDelimiter); - // return buf.toString(); - // } + private String constructTypeStub(String lineDelimiter) { // ImportsManager imports, String lineDelimiter) { + StringBuffer buf= new StringBuffer(); + + int modifiers= getModifiers(); + buf.append(Flags.toString(modifiers)); + if (modifiers != 0) { + buf.append(' '); + } + buf.append(fIsClass ? "class " : "interface "); //$NON-NLS-2$ //$NON-NLS-1$ + buf.append(getTypeName()); +// writeSuperClass(buf, imports); +// writeSuperInterfaces(buf, imports); + buf.append('{'); + buf.append(lineDelimiter); + buf.append(lineDelimiter); + buf.append('}'); + buf.append(lineDelimiter); + return buf.toString(); + } /** * @deprecated Overwrite createTypeMembers(IType, IImportsManager, IProgressMonitor) instead @@ -1583,24 +1585,24 @@ public abstract class NewTypeWizardPage extends NewContainerWizardPage { * @return the type comment or null if a type comment * is not desired */ - // protected String getTypeComment(ICompilationUnit parentCU) { - // if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.CODEGEN_ADD_COMMENTS)) { - // try { - // StringBuffer typeName= new StringBuffer(); - // if (isEnclosingTypeSelected()) { - // typeName.append(JavaModelUtil.getTypeQualifiedName(getEnclosingType())).append('.'); - // } - // typeName.append(getTypeName()); - // String comment= CodeGeneration.getTypeComment(parentCU, typeName.toString(), String.valueOf('\n')); - // if (comment != null && isValidComment(comment)) { - // return comment; - // } - // } catch (CoreException e) { - // PHPeclipsePlugin.log(e); - // } - // } - // return null; - // } + protected String getTypeComment(ICompilationUnit parentCU) { + if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.CODEGEN_ADD_COMMENTS)) { + try { + StringBuffer typeName= new StringBuffer(); + if (isEnclosingTypeSelected()) { + typeName.append(JavaModelUtil.getTypeQualifiedName(getEnclosingType())).append('.'); + } + typeName.append(getTypeName()); + String comment= CodeGeneration.getTypeComment(parentCU, typeName.toString(), String.valueOf('\n')); + if (comment != null && isValidComment(comment)) { + return comment; + } + } catch (CoreException e) { + PHPeclipsePlugin.log(e); + } + } + return null; + } /** * @deprecated Use getTemplate(String,ICompilationUnit,int) @@ -1625,10 +1627,16 @@ public abstract class NewTypeWizardPage extends NewContainerWizardPage { try { Template[] templates = Templates.getInstance().getTemplates(name); if (templates.length > 0) { - return JavaContext.evaluateTemplate(templates[0], parentCU, pos); + return JavaContext.evaluateTemplate(templates[0], parentCU, pos); } } catch (CoreException e) { PHPeclipsePlugin.log(e); + } catch (BadLocationException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (TemplateException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); } return null; }