X-Git-Url: http://git.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 a73147a..45b6763 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 @@ -23,12 +23,15 @@ import net.sourceforge.phpdt.core.IType; import net.sourceforge.phpdt.core.ToolFactory; import net.sourceforge.phpdt.core.compiler.IScanner; import net.sourceforge.phpdt.core.compiler.ITerminalSymbols; +import net.sourceforge.phpdt.core.compiler.ITerminalSymbols.TokenName; import net.sourceforge.phpdt.core.compiler.InvalidInputException; -import net.sourceforge.phpdt.externaltools.internal.ui.StatusInfo; +//incastrix +//import net.sourceforge.phpdt.externaltools.internal.ui.StatusInfo; +import net.sourceforge.phpeclipse.ui.StatusInfo; import net.sourceforge.phpdt.internal.corext.codemanipulation.StubUtility; -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.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; @@ -44,19 +47,19 @@ 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.CodeGeneration; -import net.sourceforge.phpdt.ui.PreferenceConstants; -import net.sourceforge.phpeclipse.PHPeclipsePlugin; +//import net.sourceforge.phpdt.ui.CodeGeneration; +//import net.sourceforge.phpdt.ui.PreferenceConstants; +//import net.sourceforge.phpeclipse.PHPeclipsePlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; 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.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; @@ -700,7 +703,7 @@ public abstract class NewTypeWizardPage extends NewContainerWizardPage { * @see net.sourceforge.phpdt.ui.wizards.NewContainerWizardPage#handleFieldChanged(String) */ protected void handleFieldChanged(String fieldName) { - super.handleFieldChanged(fieldName); + //super.handleFieldChanged(fieldName); if (fieldName == CONTAINER) { fPackageStatus = packageChanged(); // fEnclosingTypeStatus= enclosingTypeChanged(); @@ -726,9 +729,9 @@ public abstract class NewTypeWizardPage extends NewContainerWizardPage { * * @return the text of the enclosing type input field */ - public String getEnclosingTypeText() { - return fEnclosingTypeDialogField.getText(); - } +// public String getEnclosingTypeText() { +// return fEnclosingTypeDialogField.getText(); +// } /** * Returns the package fragment corresponding to the current input. @@ -851,27 +854,27 @@ public abstract class NewTypeWizardPage extends NewContainerWizardPage { * @return the selected modifiers * @see Flags */ - public int getModifiers() { - int mdf = 0; - if (fAccMdfButtons.isSelected(PUBLIC_INDEX)) { - mdf += F_PUBLIC; - } else if (fAccMdfButtons.isSelected(PRIVATE_INDEX)) { - mdf += F_PRIVATE; - } else if (fAccMdfButtons.isSelected(PROTECTED_INDEX)) { - mdf += F_PROTECTED; - } - // if (fOtherMdfButtons.isSelected(ABSTRACT_INDEX) && (fStaticMdfIndex - // != 0)) { - // mdf+= F_ABSTRACT; - // } - if (fOtherMdfButtons.isSelected(FINAL_INDEX)) { - mdf += F_FINAL; - } - if (fOtherMdfButtons.isSelected(fStaticMdfIndex)) { - mdf += F_STATIC; - } - return mdf; - } +// public int getModifiers() { +// int mdf = 0; +// if (fAccMdfButtons.isSelected(PUBLIC_INDEX)) { +// mdf += F_PUBLIC; +// } else if (fAccMdfButtons.isSelected(PRIVATE_INDEX)) { +// mdf += F_PRIVATE; +// } else if (fAccMdfButtons.isSelected(PROTECTED_INDEX)) { +// mdf += F_PROTECTED; +// } +// // if (fOtherMdfButtons.isSelected(ABSTRACT_INDEX) && (fStaticMdfIndex +// // != 0)) { +// // mdf+= F_ABSTRACT; +// // } +// if (fOtherMdfButtons.isSelected(FINAL_INDEX)) { +// mdf += F_FINAL; +// } +// if (fOtherMdfButtons.isSelected(fStaticMdfIndex)) { +// mdf += F_STATIC; +// } +// return mdf; +// } /** * Sets the modifiers. @@ -885,38 +888,38 @@ public abstract class NewTypeWizardPage extends NewContainerWizardPage { * otherwise they are read-only * @see Flags */ - public void setModifiers(int modifiers, boolean canBeModified) { - if (Flags.isPublic(modifiers)) { - fAccMdfButtons.setSelection(PUBLIC_INDEX, true); - } else if (Flags.isPrivate(modifiers)) { - fAccMdfButtons.setSelection(PRIVATE_INDEX, true); - } else if (Flags.isProtected(modifiers)) { - fAccMdfButtons.setSelection(PROTECTED_INDEX, true); - } else { - fAccMdfButtons.setSelection(DEFAULT_INDEX, true); - } - // if (Flags.isAbstract(modifiers)) { - // fOtherMdfButtons.setSelection(ABSTRACT_INDEX, true); - // } - if (Flags.isFinal(modifiers)) { - fOtherMdfButtons.setSelection(FINAL_INDEX, true); - } - if (Flags.isStatic(modifiers)) { - fOtherMdfButtons.setSelection(fStaticMdfIndex, true); - } - - fAccMdfButtons.setEnabled(canBeModified); - fOtherMdfButtons.setEnabled(canBeModified); - } +// public void setModifiers(int modifiers, boolean canBeModified) { +// if (Flags.isPublic(modifiers)) { +// fAccMdfButtons.setSelection(PUBLIC_INDEX, true); +// } else if (Flags.isPrivate(modifiers)) { +// fAccMdfButtons.setSelection(PRIVATE_INDEX, true); +// } else if (Flags.isProtected(modifiers)) { +// fAccMdfButtons.setSelection(PROTECTED_INDEX, true); +// } else { +// fAccMdfButtons.setSelection(DEFAULT_INDEX, true); +// } +// // if (Flags.isAbstract(modifiers)) { +// // fOtherMdfButtons.setSelection(ABSTRACT_INDEX, true); +// // } +// if (Flags.isFinal(modifiers)) { +// fOtherMdfButtons.setSelection(FINAL_INDEX, true); +// } +// if (Flags.isStatic(modifiers)) { +// fOtherMdfButtons.setSelection(fStaticMdfIndex, true); +// } +// +// fAccMdfButtons.setEnabled(canBeModified); +// fOtherMdfButtons.setEnabled(canBeModified); +// } /** * Returns the content of the superclass input field. * * @return the superclass name */ - public String getSuperClass() { - return fSuperClassDialogField.getText(); - } +// public String getSuperClass() { +// return fSuperClassDialogField.getText(); +// } /** * Sets the super class name. @@ -938,9 +941,9 @@ public abstract class NewTypeWizardPage extends NewContainerWizardPage { * @return a list of chosen super interfaces. The list's elements are of * type String */ - public List getSuperInterfaces() { - return fSuperInterfacesDialogField.getElements(); - } +// public List getSuperInterfaces() { +// return fSuperInterfacesDialogField.getElements(); +// } /** * Sets the super interfaces. @@ -1331,7 +1334,8 @@ public abstract class NewTypeWizardPage extends NewContainerWizardPage { */ protected IStatus modifiersChanged() { StatusInfo status = new StatusInfo(); - int modifiers = getModifiers(); + //int modifiers = getModifiers(); + // if (Flags.isFinal(modifiers) && Flags.isAbstract(modifiers)) { // status.setError(NewWizardMessages.getString("NewTypeWizardPage.error.ModifiersFinalAndAbstract")); // //$NON-NLS-1$ @@ -1483,7 +1487,7 @@ public abstract class NewTypeWizardPage extends NewContainerWizardPage { // ImportsStructure imports; int indent = 0; - IPreferenceStore store = PreferenceConstants.getPreferenceStore(); + //IPreferenceStore store = PreferenceConstants.getPreferenceStore(); // String[] prefOrder = // JavaPreferencesSettings.getImportOrderPreference(store); // int threshold = @@ -1506,7 +1510,7 @@ public abstract class NewTypeWizardPage extends NewContainerWizardPage { // solves 14661 // imports.addImport(pack.getElementName(), getTypeName()); // - String typeContent = constructTypeStub(lineDelimiter);// new + //String typeContent = constructTypeStub(lineDelimiter);// new // ImportsManager(imports), // lineDelimiter); @@ -1694,29 +1698,29 @@ public abstract class NewTypeWizardPage extends NewContainerWizardPage { /* * Called from createType to construct the source for this type */ - 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(); - } +// 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, @@ -1775,13 +1779,13 @@ public abstract class NewTypeWizardPage extends NewContainerWizardPage { // false); scanner.setSource(template.toCharArray()); try { - int next = scanner.getNextToken(); - while (next == ITerminalSymbols.TokenNameCOMMENT_LINE - || next == ITerminalSymbols.TokenNameCOMMENT_PHPDOC - || next == ITerminalSymbols.TokenNameCOMMENT_BLOCK) { + TokenName next = scanner.getNextToken(); + while (next == ITerminalSymbols.TokenName.COMMENT_LINE + || next == ITerminalSymbols.TokenName.COMMENT_PHPDOC + || next == ITerminalSymbols.TokenName.COMMENT_BLOCK) { next = scanner.getNextToken(); } - return next == ITerminalSymbols.TokenNameEOF; + return next == ITerminalSymbols.TokenName.EOF; } catch (InvalidInputException e) { } return false; @@ -1795,36 +1799,36 @@ 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) */ - protected String getTemplate(String name, ICompilationUnit parentCU) { - return getTemplate(name, parentCU, 0); - } +// protected String getTemplate(String name, ICompilationUnit parentCU) { +// return getTemplate(name, parentCU, 0); +// } /** * Returns the string resulting from evaluation the given template in the @@ -1841,24 +1845,24 @@ public abstract class NewTypeWizardPage extends NewContainerWizardPage { * a source offset into the parent compilation unit. The template * is evalutated at the given source offset */ - protected String getTemplate(String name, ICompilationUnit parentCU, int pos) { - try { - Template[] templates = Templates.getInstance().getTemplates(name); - if (templates.length > 0) { - 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; - } +// protected String getTemplate(String name, ICompilationUnit parentCU, int pos) { +// try { +// Template[] templates = Templates.getInstance().getTemplates(name); +// if (templates.length > 0) { +// 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; +// } /** * @deprecated Use @@ -1951,4 +1955,4 @@ public abstract class NewTypeWizardPage extends NewContainerWizardPage { // } // }; // } -} +} \ No newline at end of file