List of usage examples for org.eclipse.jdt.core IJavaProject getElementName
String getElementName();
From source file:ca.ecliptical.pde.internal.ds.DSAnnotationCompilationParticipant.java
License:Open Source License
@Override public void buildFinished(IJavaProject project) { ProjectContext projectContext = processingContext.remove(project); if (projectContext != null) { ProjectState state = projectContext.getState(); // check if unprocessed CUs still exist; if not, their mapped files are now abandoned Map<String, Collection<String>> cuMap = state.getMappings(); HashSet<String> abandoned = new HashSet<String>(projectContext.getAbandoned()); for (String cuKey : projectContext.getUnprocessed()) { boolean exists = false; try { IType cuType = project.findType(cuKey); IResource file;/* w w w . j ava 2s . c om*/ if (cuType != null && (file = cuType.getResource()) != null && file.exists()) exists = true; } catch (JavaModelException e) { Activator.getDefault().getLog().log(e.getStatus()); } if (!exists) { if (debug.isDebugging()) debug.trace(String.format("Mapped CU %s no longer exists.", cuKey)); //$NON-NLS-1$ Collection<String> dsKeys = cuMap.remove(cuKey); if (dsKeys != null) abandoned.addAll(dsKeys); } } // remove CUs with no mapped DS models HashSet<String> retained = new HashSet<String>(); for (Iterator<Map.Entry<String, Collection<String>>> i = cuMap.entrySet().iterator(); i.hasNext();) { Map.Entry<String, Collection<String>> entry = i.next(); Collection<String> dsKeys = entry.getValue(); if (dsKeys.isEmpty()) i.remove(); else retained.addAll(dsKeys); } // retain abandoned files that are still mapped elsewhere abandoned.removeAll(retained); if (projectContext.isChanged()) { try { saveState(project.getProject(), state); } catch (IOException e) { Activator.getDefault().getLog() .log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error saving file mappings.", e)); //$NON-NLS-1$ } } // delete all abandoned files ArrayList<IStatus> deleteStatuses = new ArrayList<IStatus>(2); for (String dsKey : abandoned) { IPath path = Path.fromPortableString(dsKey); if (debug.isDebugging()) debug.trace(String.format("Deleting %s", path)); //$NON-NLS-1$ IFile file = PDEProject.getBundleRelativeFile(project.getProject(), path); if (file.exists()) { try { file.delete(true, null); } catch (CoreException e) { deleteStatuses.add(e.getStatus()); } } } if (!deleteStatuses.isEmpty()) Activator.getDefault().getLog() .log(new MultiStatus(Activator.PLUGIN_ID, 0, deleteStatuses.toArray(new IStatus[deleteStatuses.size()]), "Error deleting generated files.", null)); //$NON-NLS-1$ writeManifest(project.getProject(), retained, abandoned); writeBuildProperties(project.getProject(), retained, abandoned); } if (debug.isDebugging()) debug.trace(String.format("Build finished for project: %s", project.getElementName())); //$NON-NLS-1$ }
From source file:cc.frz.ecl.filterpackageexplorer.FilterContentProvider.java
License:Open Source License
private boolean matchesFilter(IJavaProject jp) { return pattern.matches(jp.getElementName()); }
From source file:cc.kave.eclipse.namefactory.astparser.PluginAstParser.java
License:Apache License
private ICompilationUnit getCompilationunit(String project, String qualifiedName) { String[] split = qualifiedName.split(";"); for (IJavaProject iJavaProject : javaProjects) { if (iJavaProject.getElementName().equals(project)) { try { return iJavaProject.findType(split[0], split[1]).getCompilationUnit(); } catch (JavaModelException e) { e.printStackTrace();// w w w . j a v a 2 s .co m } } } return null; }
From source file:cfgrecognition.views.ProjectNameDialog.java
License:Open Source License
private void addTable() throws Exception { // Add table to the dialog table = new Table(dialog, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION); // GridData data = new GridData (SWT.FILL, SWT.FILL, true, true); GridData data = new GridData(); data.heightHint = 200;/*w w w . j av a 2 s . c o m*/ data.horizontalSpan = 2; data.horizontalAlignment = SWT.FILL; data.verticalAlignment = SWT.FILL; table.setLayoutData(data); table.setLinesVisible(true); table.setHeaderVisible(true); TableColumn column = new TableColumn(table, SWT.LEAD); column.setText("Java Project List"); JavaElementLabelProvider labelProvider = new JavaElementLabelProvider(); IJavaModel javaModel = Activator.getJavaModel(); IJavaProject[] javaProjects = javaModel.getJavaProjects(); TreeSet<IJavaProject> set = new TreeSet<IJavaProject>(new Comparator<IJavaProject>() { public int compare(IJavaProject thisP, IJavaProject thatP) { return thisP.getElementName().compareTo(thatP.getElementName()); } }); set.addAll(Arrays.asList(javaProjects)); for (IJavaProject javaProject : set) { TableItem item = new TableItem(table, SWT.NULL); item.setText(javaProject.getElementName()); item.setImage(labelProvider.getImage(javaProject)); item.setData(javaProject); } column.pack(); column.setWidth(300); }
From source file:ch.powerunit.poweruniteclipse.tab.PowerUnitLaunchTabProject.java
License:Open Source License
public void setProject(IJavaProject project) { fProjText.setText(project.getElementName()); }
From source file:ch.powerunit.poweruniteclipse.tab.PowerUnitLaunchTabProject.java
License:Open Source License
private void handleProjectButtonSelected() { IJavaProject project = chooseJavaProject(); if (project == null) { return;/*from w w w . ja v a2 s . c o m*/ } String projectName = project.getElementName(); fProjText.setText(projectName); }
From source file:cn.dockerfoundry.ide.eclipse.server.core.internal.debug.DockerFoundryDebugSourceLocator.java
License:Open Source License
public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException { List<IRuntimeClasspathEntry> entries = new ArrayList<IRuntimeClasspathEntry>(); IRuntimeClasspathEntry jreEntry = JavaRuntime.computeJREEntry(configuration); if (jreEntry != null) { entries.add(jreEntry);/*from ww w.ja va 2s . c o m*/ } String projectName = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$ if (projectName == null) { return null; } for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) { IJavaProject javaProject = JavaCore.create(project); if (javaProject != null && javaProject.isOpen() && ("".equals(projectName) || projectName.equals(javaProject.getElementName()))) { //$NON-NLS-1$ entries.add(JavaRuntime.newDefaultProjectClasspathEntry(javaProject)); } } IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveSourceLookupPath( // entries.toArray(new IRuntimeClasspathEntry[entries.size()]), configuration); return JavaRuntime.getSourceContainers(resolved); }
From source file:com.android.ide.eclipse.adt.internal.launch.EmulatorConfigTab.java
License:Open Source License
@Override public void initializeFrom(ILaunchConfiguration configuration) { AvdManager avdManager = Sdk.getCurrent().getAvdManager(); TargetMode mode = AndroidLaunchConfiguration.parseTargetMode(configuration, LaunchConfigDelegate.DEFAULT_TARGET_MODE); boolean multipleDevices = mode.isMultiDevice(); if (multipleDevices && !mSupportMultiDeviceLaunch) { // The launch config says to run on multiple devices, but this launch type does not // suppport multiple devices. In such a case, switch back to default mode. // This could happen if a launch config used for Run is then used for Debug. multipleDevices = false;//ww w . j a v a 2 s.co m mode = LaunchConfigDelegate.DEFAULT_TARGET_MODE; } mAutoTargetButton.setSelection(mode == TargetMode.AUTO); mManualTargetButton.setSelection(mode == TargetMode.MANUAL); mAllDevicesTargetButton.setSelection(multipleDevices); targetModeChanged(); boolean reuseLastUsedDevice; try { reuseLastUsedDevice = configuration.getAttribute(LaunchConfigDelegate.ATTR_REUSE_LAST_USED_DEVICE, false); } catch (CoreException ex) { reuseLastUsedDevice = false; } mFutureLaunchesOnSameDevice.setSelection(reuseLastUsedDevice); mDeviceTypeCombo.setEnabled(multipleDevices); if (multipleDevices) { int index = 0; if (mode == TargetMode.ALL_EMULATORS) { index = 1; } else if (mode == TargetMode.ALL_DEVICES) { index = 2; } mDeviceTypeCombo.select(index); } // look for the project name to get its target. String stringValue = ""; try { stringValue = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, stringValue); } catch (CoreException ce) { // let's not do anything here, we'll use the default value } IProject project = null; // get the list of existing Android projects from the workspace. IJavaProject[] projects = BaseProjectHelper.getAndroidProjects(null /*filter*/); if (projects != null) { // look for the project whose name we read from the configuration. for (IJavaProject p : projects) { if (p.getElementName().equals(stringValue)) { project = p.getProject(); break; } } } // update the AVD list if (project != null) { mProjectTarget = Sdk.getCurrent().getTarget(project); ManifestInfo mi = ManifestInfo.get(project); final int minApiLevel = mi.getMinSdkVersion(); final String minApiCodeName = mi.getMinSdkCodeName(); mProjectMinApiVersion = new AndroidVersion(minApiLevel, minApiCodeName); } updateAvdList(avdManager); stringValue = ""; try { stringValue = configuration.getAttribute(LaunchConfigDelegate.ATTR_AVD_NAME, stringValue); } catch (CoreException e) { // let's not do anything here, we'll use the default value } if (stringValue != null && stringValue.length() > 0 && avdManager != null) { AvdInfo targetAvd = avdManager.getAvd(stringValue, true /*validAvdOnly*/); mPreferredAvdSelector.setSelection(targetAvd); } else { mPreferredAvdSelector.setSelection(null); } boolean value = LaunchConfigDelegate.DEFAULT_WIPE_DATA; try { value = configuration.getAttribute(LaunchConfigDelegate.ATTR_WIPE_DATA, value); } catch (CoreException e) { // let's not do anything here, we'll use the default value } mWipeDataButton.setSelection(value); value = LaunchConfigDelegate.DEFAULT_NO_BOOT_ANIM; try { value = configuration.getAttribute(LaunchConfigDelegate.ATTR_NO_BOOT_ANIM, value); } catch (CoreException e) { // let's not do anything here, we'll use the default value } mNoBootAnimButton.setSelection(value); int index = -1; index = LaunchConfigDelegate.DEFAULT_SPEED; try { index = configuration.getAttribute(LaunchConfigDelegate.ATTR_SPEED, index); } catch (CoreException e) { // let's not do anything here, we'll use the default value } if (index == -1) { mSpeedCombo.clearSelection(); } else { mSpeedCombo.select(index); } index = LaunchConfigDelegate.DEFAULT_DELAY; try { index = configuration.getAttribute(LaunchConfigDelegate.ATTR_DELAY, index); } catch (CoreException e) { // let's not do anything here, we'll put a proper value in // performApply anyway } if (index == -1) { mDelayCombo.clearSelection(); } else { mDelayCombo.select(index); } String commandLine = null; try { commandLine = configuration.getAttribute(LaunchConfigDelegate.ATTR_COMMANDLINE, ""); //$NON-NLS-1$ } catch (CoreException e) { // let's not do anything here, we'll use the default value } if (commandLine != null) { mEmulatorCLOptions.setText(commandLine); } }
From source file:com.android.ide.eclipse.adt.internal.launch.junit.AndroidJUnitLaunchConfigurationTab.java
License:Open Source License
/** * Show a dialog that lists all main types *//*from ww w . java 2 s . c o m*/ private void handleSearchButtonSelected() { Shell shell = getShell(); IJavaProject javaProject = getJavaProject(); IType[] types = new IType[0]; boolean[] radioSetting = new boolean[2]; try { // fix for Eclipse bug 66922 Wrong radio behaviour when switching // remember the selected radio button radioSetting[0] = mTestRadioButton.getSelection(); radioSetting[1] = mTestContainerRadioButton.getSelection(); types = TestSearchEngine.findTests(getLaunchConfigurationDialog(), javaProject, getTestKind()); } catch (InterruptedException e) { setErrorMessage(e.getMessage()); return; } catch (InvocationTargetException e) { AdtPlugin.log(e.getTargetException(), "Error finding test types"); //$NON-NLS-1$ return; } finally { mTestRadioButton.setSelection(radioSetting[0]); mTestContainerRadioButton.setSelection(radioSetting[1]); } SelectionDialog dialog = new TestSelectionDialog(shell, types); dialog.setTitle(JUnitMessages.JUnitLaunchConfigurationTab_testdialog_title); dialog.setMessage(JUnitMessages.JUnitLaunchConfigurationTab_testdialog_message); if (dialog.open() == Window.CANCEL) { return; } Object[] results = dialog.getResult(); if ((results == null) || (results.length < 1)) { return; } IType type = (IType) results[0]; if (type != null) { mTestText.setText(type.getFullyQualifiedName('.')); javaProject = type.getJavaProject(); mProjText.setText(javaProject.getElementName()); } }
From source file:com.android.ide.eclipse.adt.internal.launch.junit.AndroidJUnitLaunchConfigurationTab.java
License:Open Source License
/** * Show a dialog that lets the user select a Android project. This in turn provides * context for the main type, allowing the user to key a main type name, or * constraining the search for main types to the specified project. *//*from w w w . ja v a 2 s . co m*/ private void handleProjectButtonSelected() { IJavaProject project = mProjectChooserHelper.chooseJavaProject(getProjectName(), "Please select a project to launch"); if (project == null) { return; } String projectName = project.getElementName(); mProjText.setText(projectName); loadInstrumentations(project.getProject()); }