List of usage examples for org.eclipse.jdt.core IType getTypeQualifiedName
String getTypeQualifiedName(char enclosingTypeSeparator);
From source file:ch.powerunit.poweruniteclipse.PowerunitlaunchConfigurationShortcut.java
License:Open Source License
@Override protected ILaunchConfiguration createConfiguration(IType type) { ILaunchConfiguration config = null;//from w w w. jav a2 s.c o m ILaunchConfigurationWorkingCopy wc = null; try { ILaunchConfigurationType configType = getConfigurationType(); wc = configType.newInstance(null, getLaunchManager().generateLaunchConfigurationName(type.getTypeQualifiedName('.'))); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, type.getCompilationUnit().getJavaProject().getElementName()); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, type.getFullyQualifiedName()); config = wc.doSave(); } catch (CoreException exception) { MessageDialog.openError(JDIDebugUIPlugin.getActiveWorkbenchShell(), LauncherMessages.JavaLaunchShortcut_3, exception.getStatus().getMessage()); } return config; }
From source file:cn.ieclipse.adt.ext.wizards.NewActivityWizardPage.java
License:Apache License
private void generateOnCreate(IType type, ImportsManager imports) throws CoreException, JavaModelException { StringBuilder buf = new StringBuilder(); final String lineDelim = "\n"; // OK, since content is formatted afterwards //$NON-NLS-1$ buf.append("/* (non-Javadoc)").append(lineDelim); buf.append("* @see android.app.Activity#onCreate(android.os.Bundle)").append(lineDelim); buf.append("*/").append(lineDelim); buf.append("@Override"); buf.append(lineDelim);/*from w w w .j a v a 2s .co m*/ buf.append("public void onCreate("); //$NON-NLS-1$ buf.append(imports.addImport("android.os.Bundle")); //$NON-NLS-1$ buf.append(" savedInstanceState) {"); //$NON-NLS-1$ buf.append(lineDelim); buf.append("super.onCreate(savedInstanceState);"); buf.append(lineDelim); final String content = CodeGeneration.getMethodBodyContent(type.getCompilationUnit(), type.getTypeQualifiedName('.'), "onCreate", false, "", lineDelim); //$NON-NLS-1$ //$NON-NLS-2$ if (content != null && content.length() != 0) buf.append(content); buf.append(lineDelim); buf.append("}"); //$NON-NLS-1$ type.createMethod(buf.toString(), null, false, null); }
From source file:cn.ieclipse.adt.ext.wizards.NewActivityWizardPage.java
License:Apache License
private void generateOnStartCommand(IType type, ImportsManager imports) throws CoreException, JavaModelException { StringBuilder buf = new StringBuilder(); final String lineDelim = "\n"; // OK, since content is formatted afterwards //$NON-NLS-1$ buf.append("/* (non-Javadoc)").append(lineDelim); buf.append("* @see android.app.Service#onStartCommand(android.content.Intent, int, int)").append(lineDelim); buf.append("*/").append(lineDelim); buf.append("@Override"); buf.append(lineDelim);/*from ww w . j av a2 s .c o m*/ buf.append("public int onStartCommand("); //$NON-NLS-1$ buf.append(imports.addImport("android.content.Intent")); //$NON-NLS-1$ buf.append(" intent, int flags, int startId) {"); //$NON-NLS-1$ buf.append(lineDelim); final String content = CodeGeneration.getMethodBodyContent(type.getCompilationUnit(), type.getTypeQualifiedName('.'), "super.onStartCommand", false, "", lineDelim); //$NON-NLS-1$ //$NON-NLS-2$ if (content != null && content.length() != 0) buf.append(content); buf.append(lineDelim); buf.append("return super.onStartCommand(intent, flags, startId);"); buf.append(lineDelim); buf.append("}"); //$NON-NLS-1$ type.createMethod(buf.toString(), null, false, null); }
From source file:cn.ieclipse.adt.ext.wizards.NewActivityWizardPage.java
License:Apache License
private void generateStub(String method, IType type, ImportsManager imports) throws CoreException, JavaModelException { List<String> supers = ProjectHelper.getSuperTypeName(getJavaProject(), getSuperClass(), false); if (supers.contains(AdtConstants.ACTIVITY_QNAME) && "onCreate".equals(method)) { generateOnCreate(type, imports); return;//w w w.j av a 2 s. c om } else if (supers.contains(AdtConstants.SERVICE_QNAME) && "onStartCommand".equals(method)) { generateOnStartCommand(type, imports); return; } StringBuilder buf = new StringBuilder(); final String lineDelim = "\n"; // OK, since content is formatted afterwards //$NON-NLS-1$ buf.append("/* (non-Javadoc)").append(lineDelim); buf.append("* @see " + getSuperClass() + "#" + method + "()").append(lineDelim); buf.append("*/").append(lineDelim); buf.append("@Override"); buf.append(lineDelim); buf.append("public void " + method + "(){"); //$NON-NLS-1$ // buf.append(lineDelim); buf.append("super." + method + "();"); buf.append(lineDelim); final String content = CodeGeneration.getMethodBodyContent(type.getCompilationUnit(), type.getTypeQualifiedName('.'), method, false, "", lineDelim); //$NON-NLS-1$ //$NON-NLS-2$ if (content != null && content.length() != 0) buf.append(content); buf.append(lineDelim); buf.append("}"); //$NON-NLS-1$ type.createMethod(buf.toString(), null, false, null); }
From source file:com.aliyun.odps.eclipse.launch.shortcut.ODPSApplicationShortcut.java
License:Apache License
protected ILaunchConfiguration createConfiguration(IType type) { ILaunchConfiguration config = null;/*from w w w . jav a 2 s . c o m*/ ILaunchConfigurationWorkingCopy wc = null; try { // ILaunchConfigurationType configType = // DebugPlugin.getDefault().getLaunchManager() // .getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION); ILaunchConfigurationType configType = DebugPlugin.getDefault().getLaunchManager() .getLaunchConfigurationType(OdpsEclipseConstants.LAUNCH_CONFIGURATION_TYPE); wc = configType.newInstance(null, DebugPlugin.getDefault().getLaunchManager() .generateLaunchConfigurationName(type.getTypeQualifiedName('.'))); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, type.getFullyQualifiedName()); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, type.getJavaProject().getElementName()); wc.setMappedResources(new IResource[] { type.getUnderlyingResource() }); config = wc.doSave(); } catch (CoreException exception) { MessageDialog.openError(JDIDebugUIPlugin.getActiveWorkbenchShell(), LauncherMessages.JavaLaunchShortcut_3, exception.getStatus().getMessage()); } return config; }
From source file:com.aliyun.odps.eclipse.launch.shortcut.udf.UDFLaunchShortcuts.java
License:Apache License
protected ILaunchConfiguration createConfiguration(IType type) { ILaunchConfiguration config = null;/*from ww w. j av a 2 s . c o m*/ ILaunchConfigurationWorkingCopy wc = null; try { // ILaunchConfigurationType configType = // DebugPlugin.getDefault().getLaunchManager() // .getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION); ILaunchConfigurationType configType = DebugPlugin.getDefault().getLaunchManager() .getLaunchConfigurationType(LaunchConfigurationConstants.ID_LAUNCH_CONFIGURATION_ODPS_UDF); wc = configType.newInstance(null, DebugPlugin.getDefault().getLaunchManager() .generateLaunchConfigurationName(type.getTypeQualifiedName('.'))); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, type.getFullyQualifiedName()); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, type.getJavaProject().getElementName()); wc.setMappedResources(new IResource[] { type.getUnderlyingResource() }); config = wc.doSave(); } catch (CoreException exception) { MessageDialog.openError(JDIDebugUIPlugin.getActiveWorkbenchShell(), LauncherMessages.JavaLaunchShortcut_3, exception.getStatus().getMessage()); } return config; }
From source file:com.aliyun.odps.eclipse.launch.shortcut.udf.UDFLaunchShortcuts2.java
License:Apache License
protected ILaunchConfiguration createConfiguration(IType type) { ILaunchConfiguration config = null;/*from w ww. j av a2 s . com*/ ILaunchConfigurationWorkingCopy wc = null; try { ILaunchConfigurationType configType = getConfigurationType(); wc = configType.newInstance(null, getLaunchManager().generateLaunchConfigurationName(type.getTypeQualifiedName('.'))); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, type.getFullyQualifiedName()); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, type.getJavaProject().getElementName()); wc.setMappedResources(new IResource[] { type.getUnderlyingResource() }); config = wc.doSave(); } catch (CoreException exception) { MessageDialog.openError(JDIDebugUIPlugin.getActiveWorkbenchShell(), LauncherMessages.JavaLaunchShortcut_3, exception.getStatus().getMessage()); } return config; }
From source file:com.codenvy.ide.ext.java.server.internal.core.NamedMember.java
License:Open Source License
protected String getKey(IType type, boolean forceOpen) throws JavaModelException { StringBuffer key = new StringBuffer(); key.append('L'); String packageName = type.getPackageFragment().getElementName(); key.append(packageName.replace('.', '/')); if (packageName.length() > 0) key.append('/'); String typeQualifiedName = type.getTypeQualifiedName('$'); ICompilationUnit cu = (ICompilationUnit) type.getAncestor(IJavaElement.COMPILATION_UNIT); if (cu != null) { String cuName = cu.getElementName(); String mainTypeName = cuName.substring(0, cuName.lastIndexOf('.')); int end = typeQualifiedName.indexOf('$'); if (end == -1) end = typeQualifiedName.length(); String topLevelTypeName = typeQualifiedName.substring(0, end); if (!mainTypeName.equals(topLevelTypeName)) { key.append(mainTypeName);//from ww w .j av a 2 s . c o m key.append('~'); } } key.append(typeQualifiedName); key.append(';'); return key.toString(); }
From source file:com.codenvy.ide.ext.java.server.javadoc.JavaDocLocations.java
License:Open Source License
private static void appendTypePath(IType type, StringBuffer buf) { IPackageFragment pack = type.getPackageFragment(); String packPath = pack.getElementName().replace('.', '/'); String typePath = type.getTypeQualifiedName('.'); if (packPath.length() > 0) { buf.append(packPath);/*from ww w . j a va 2s .c o m*/ buf.append('/'); } buf.append(typePath); buf.append(".html"); //$NON-NLS-1$ }
From source file:com.google.gdt.eclipse.appengine.rpc.util.CompilationUnitCreator.java
License:Open Source License
/** * Adds a method to the service class/*from w w w . j av a 2 s. co m*/ */ private void constructServiceMethod(IType type, String methodName, boolean hasReturnType, String[] paramType, String[] paramName, ImportsManager imports, IProgressMonitor monitor) throws CoreException { StringBuffer buf = new StringBuffer(); buf.append("public static "); //$NON-NLS-1$ if (hasReturnType) { if (methodName.startsWith(" query")) { //$NON-NLS-1$ buf.append(imports.addImport("java.util.List")); buf.append("<"); //$NON-NLS-N$ buf.append(imports.addImport(current.getFullyQualifiedName())); buf.append(">"); //$NON-NLS-N$ } else { buf.append(imports.addImport(current.getFullyQualifiedName())); } } else { buf.append("void"); //$NON-NLS-1$ } buf.append(methodName); buf.append("("); //$NON-NLS-N$ if (paramType != null) { for (int i = 0; i < paramType.length; i++) { if (i > 0) { buf.append(", "); //$NON-NLS-N$ } buf.append(imports.addImport(paramType[i])); buf.append(paramName[i]); } } buf.append(") {"); //$NON-NLS-1$ buf.append(lineDelimiter); final String content = CodeGeneration.getMethodBodyContent(type.getCompilationUnit(), type.getTypeQualifiedName('.'), methodName, false, "", lineDelimiter); //$NON-NLS-1$ //$NON-NLS-2$ if (content != null && content.length() != 0) buf.append(content); if (hasReturnType) { buf.append("return null;"); //$NON-NLS-1$ } buf.append(lineDelimiter); buf.append("}"); //$NON-NLS-1$ type.createMethod(buf.toString(), null, false, null); if (monitor != null) { monitor.done(); } }