List of usage examples for org.eclipse.jdt.core IJavaProject getProject
IProject getProject();
IProject
on which this IJavaProject
was created. From source file:com.hudson.hibernatesynchronizer.wizard.NewConfigurationWizardPage.java
License:GNU General Public License
/** * Tests if the current workbench selection is a suitable container to use. *//* w w w . j av a 2 s.c om*/ private void initialize() { if (selection != null && selection.isEmpty() == false && selection instanceof IStructuredSelection) { IStructuredSelection ssel = (IStructuredSelection) selection; if (ssel.size() == 1) { Object obj = ssel.getFirstElement(); if (obj instanceof IResource) { IContainer cont; if (obj instanceof IContainer) cont = (IContainer) obj; else cont = ((IResource) obj).getParent(); containerText.setText(cont.getFullPath().toString()); projectChanged(((IResource) obj).getProject()); } else if (obj instanceof IPackageFragment) { IPackageFragment frag = (IPackageFragment) obj; containerText.setText(frag.getPath().toString()); projectChanged(frag.getJavaProject().getProject()); } else if (obj instanceof IPackageFragmentRoot) { IPackageFragmentRoot root = (IPackageFragmentRoot) obj; containerText.setText(root.getPath().toString()); projectChanged(root.getJavaProject().getProject()); } else if (obj instanceof IJavaProject) { IJavaProject proj = (IJavaProject) obj; containerText.setText("/" + proj.getProject().getName()); projectChanged(proj.getProject()); } else if (obj instanceof IProject) { IProject proj = (IProject) obj; containerText.setText("/" + proj.getName()); projectChanged(proj); } } } fileText.setText("hibernate.cfg.xml"); }
From source file:com.hudson.hibernatesynchronizer.wizard.NewMappingWizardPage.java
License:GNU General Public License
public Composite addConfiguration(Composite parent) { Composite container = new Composite(parent, SWT.NULL); GridLayout layout = new GridLayout(); container.setLayout(layout);//from w ww . j av a 2 s . co m layout.numColumns = 3; layout.verticalSpacing = 9; Label label = new Label(container, SWT.NULL); label.setText("&Container:"); containerText = new Text(container, SWT.BORDER | SWT.SINGLE); containerText.setEnabled(false); containerText.setBackground(new Color(null, 255, 255, 255)); GridData gd = new GridData(); gd.widthHint = 250; containerText.setLayoutData(gd); containerText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { dialogChanged(); } }); Button containerButton = new Button(container, SWT.NATIVE); containerButton.setText("Browse"); containerButton.addMouseListener(new ContainerMouseListener(this)); label = new Label(container, SWT.NULL); gd = new GridData(); gd.grabExcessHorizontalSpace = true; gd.horizontalSpan = 3; label.setLayoutData(gd); label = new Label(container, SWT.NULL); label.setText("&Driver:"); driverText = new Text(container, SWT.BORDER | SWT.SINGLE); driverText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { dialogChanged(); } }); driverText.setEnabled(false); driverText.setBackground(new Color(null, 255, 255, 255)); gd = new GridData(); gd.widthHint = 250; driverText.setLayoutData(gd); Button driverButton = new Button(container, SWT.NATIVE); driverButton.setText("Browse"); driverButton.addMouseListener(new DriverMouseListener(this)); label = new Label(container, SWT.NULL); label.setText("&Database URL:"); databaseUrlText = new Text(container, SWT.BORDER | SWT.SINGLE); databaseUrlText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { dialogChanged(); } }); gd = new GridData(); gd.horizontalSpan = 2; gd.widthHint = 250; databaseUrlText.setLayoutData(gd); label = new Label(container, SWT.NULL); label.setText("&Username:"); usernameText = new Text(container, SWT.BORDER | SWT.SINGLE); usernameText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { dialogChanged(); } }); gd = new GridData(); gd.horizontalSpan = 2; gd.widthHint = 150; usernameText.setLayoutData(gd); label = new Label(container, SWT.NULL); label.setText("&Password:"); passwordText = new Text(container, SWT.BORDER | SWT.SINGLE); passwordText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { dialogChanged(); } }); passwordText.setEchoChar('*'); gd = new GridData(); gd.horizontalSpan = 2; gd.widthHint = 150; passwordText.setLayoutData(gd); label = new Label(container, SWT.NULL); label.setText("Table pattern:"); tablePattern = new Text(container, SWT.BORDER | SWT.SINGLE); tablePattern.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { dialogChanged(); } }); tablePattern.setEnabled(true); tablePattern.setBackground(new Color(null, 255, 255, 255)); gd = new GridData(); gd.horizontalSpan = 2; gd.widthHint = 250; tablePattern.setLayoutData(gd); label = new Label(container, SWT.NULL); label.setText("Schema pattern:"); schemaPattern = new Text(container, SWT.BORDER | SWT.SINGLE); schemaPattern.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { dialogChanged(); } }); schemaPattern.setEnabled(true); schemaPattern.setBackground(new Color(null, 255, 255, 255)); gd = new GridData(); gd.horizontalSpan = 2; gd.widthHint = 250; schemaPattern.setLayoutData(gd); label = new Label(container, SWT.NULL); label.setText("Tables"); table = new Table(container, SWT.BORDER | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.CHECK); table.setVisible(true); table.setLinesVisible(false); table.setHeaderVisible(false); table.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { dialogChanged(); } public void widgetDefaultSelected(SelectionEvent e) { } }); GridData data = new GridData(); data.heightHint = 150; data.widthHint = 250; table.setLayoutData(data); // create the columns TableColumn nameColumn = new TableColumn(table, SWT.LEFT); ColumnLayoutData nameColumnLayout = new ColumnWeightData(100, false); // set columns in Table layout TableLayout tableLayout = new TableLayout(); tableLayout.addColumnData(nameColumnLayout); table.setLayout(tableLayout); Composite buttonContainer = new Composite(container, SWT.NULL); buttonContainer.setLayout(new GridLayout(1, true)); gd = new GridData(); gd.verticalAlignment = GridData.BEGINNING; gd.horizontalAlignment = GridData.BEGINNING; buttonContainer.setLayoutData(gd); tableRefreshButton = new Button(buttonContainer, SWT.PUSH); tableRefreshButton.setText("Refresh"); tableRefreshButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); tableRefreshButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); try { dialog.run(false, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { monitor.beginTask("Refreshing tables...", 21); refreshTables(monitor); } catch (Exception e) { throw new InvocationTargetException(e); } finally { monitor.done(); } } }); } catch (Exception exc) { } } }); selectAllButton = new Button(buttonContainer, SWT.PUSH); selectAllButton.setText("Select All"); selectAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); selectAllButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { try { for (int i = 0; i < table.getItemCount(); i++) { table.getItem(i).setChecked(true); } dialogChanged(); } catch (Exception exc) { } } }); selectNoneButton = new Button(buttonContainer, SWT.PUSH); selectNoneButton.setText("Select None"); selectNoneButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); selectNoneButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { try { for (int i = 0; i < table.getItemCount(); i++) { table.getItem(i).setChecked(false); } dialogChanged(); } catch (Exception exc) { } } }); label = new Label(container, SWT.NULL); label.setText("&Package:"); packageText = new Text(container, SWT.BORDER | SWT.SINGLE); packageText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { dialogChanged(); } }); gd = new GridData(); gd.widthHint = 250; packageText.setLayoutData(gd); packageButton = new Button(container, SWT.NATIVE); packageButton.setText("Browse"); packageButton.addMouseListener(new MouseListener() { public void mouseDown(MouseEvent e) { if (null != project) { try { IJavaSearchScope searchScope = SearchEngine.createWorkspaceScope(); SelectionDialog sd = JavaUI.createPackageDialog(getShell(), project, IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS); sd.open(); Object[] objects = sd.getResult(); if (null != objects && objects.length > 0) { IPackageFragment pf = (IPackageFragment) objects[0]; packageText.setText(pf.getElementName()); } } catch (JavaModelException jme) { jme.printStackTrace(); } } } public void mouseDoubleClick(MouseEvent e) { } public void mouseUp(MouseEvent e) { } }); if (selection != null && selection.isEmpty() == false && selection instanceof IStructuredSelection) { IStructuredSelection ssel = (IStructuredSelection) selection; if (ssel.size() == 1) { Object obj = ssel.getFirstElement(); if (obj instanceof IResource) { IContainer cont; if (obj instanceof IContainer) cont = (IContainer) obj; else cont = ((IResource) obj).getParent(); containerText.setText(cont.getFullPath().toString()); projectChanged(cont.getProject()); } else if (obj instanceof IPackageFragment) { IPackageFragment frag = (IPackageFragment) obj; containerText.setText(frag.getPath().toString()); projectChanged(frag.getJavaProject().getProject()); } else if (obj instanceof IPackageFragmentRoot) { IPackageFragmentRoot root = (IPackageFragmentRoot) obj; containerText.setText(root.getPath().toString()); projectChanged(root.getJavaProject().getProject()); } else if (obj instanceof IJavaProject) { IJavaProject proj = (IJavaProject) obj; containerText.setText("/" + proj.getProject().getName()); projectChanged(proj.getProject()); } else if (obj instanceof IProject) { IProject proj = (IProject) obj; containerText.setText("/" + proj.getName()); projectChanged(proj); } } } containerText.forceFocus(); initialize(); dialogChanged(); return container; }
From source file:com.ibm.wala.ide.util.JavaEclipseProjectPath.java
License:Open Source License
public static JavaEclipseProjectPath make(IJavaProject p, AnalysisScopeType scopeType) throws IOException, CoreException { JavaEclipseProjectPath path = new JavaEclipseProjectPath(scopeType); path.create(p.getProject()); return path;/*from w w w . jav a 2 s. c o m*/ }
From source file:com.ifedorenko.m2e.mavendev.internal.launching.MavenITLaunchDelegate.java
License:Open Source License
@Override public String getVMArguments(ILaunchConfiguration configuration) throws CoreException { final VMArguments arguments; if (launchSupport != null) { arguments = launchSupport.getVMArguments(); // maven bootclasspath, i.e. classworlds jar. arguments.appendProperty("maven.bootclasspath", quote(MavenLaunchUtils.toPath(launchSupport.getBootClasspath()))); } else {//from w w w. j a v a 2s .c o m arguments = new VMArguments(); } applyWorkspaceArtifacts(arguments); // force Verifier to use embedded maven launcher, required by m2e workspace resolution arguments.appendProperty("verifier.forkMode", "embedded"); // actual test classpath, see RemoteTestRunner arguments.appendProperty("mavendev.testclasspath", getTestClasspath(configuration)); if (configuration.getAttribute(ATTR_DETECT_CORE_ITS, true)) { IJavaProject jProject = JavaRuntime.getJavaProject(configuration); IProject project = jProject.getProject(); IMavenProjectFacade facade = MavenPlugin.getMavenProjectRegistry().getProject(project); if ("org.apache.maven.its".equals(facade.getArtifactKey().getGroupId()) && "core-it-suite".equals(facade.getArtifactKey().getArtifactId())) { // TODO need to introduce helpers to do this kind of stuff final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IFolder output = root.getFolder(facade.getTestOutputLocation()); arguments.appendProperty("maven.it.global-settings.dir", output.getLocation().toOSString()); } } extensionsSupport.appendVMArguments(arguments, configuration, launch, monitor); // user configured entries arguments.append(super.getVMArguments(configuration)); return arguments.toString(); }
From source file:com.ifedorenko.m2e.mavendev.internal.launching.Verifiers.java
License:Open Source License
private static boolean hasMavenDependency(ILaunchConfiguration configuration, String groupId, String artifactId) {//from ww w . j a va2s .c o m try { IJavaProject jproject = JavaRuntime.getJavaProject(configuration); if (jproject == null) { return false; } IMavenProjectFacade facade = MavenPlugin.getMavenProjectRegistry().getProject(jproject.getProject()); if (facade == null) { return false; } for (ArtifactRef dependency : facade.getMavenProjectArtifacts()) { if (groupId.equals(dependency.getGroupId()) && artifactId.equals(dependency.getArtifactId())) { return true; } } } catch (CoreException e) { // maybe log } return false; }
From source file:com.ifedorenko.m2e.sourcelookup.internal.JavaProjectSources.java
License:Open Source License
private void addJavaProject(IJavaProject project) throws CoreException { if (project != null) { final Map<File, IPackageFragmentRoot> classpath = new LinkedHashMap<File, IPackageFragmentRoot>(); for (IPackageFragmentRoot fragment : project.getPackageFragmentRoots()) { if (fragment.getKind() == IPackageFragmentRoot.K_BINARY && fragment.getSourceAttachmentPath() != null) { File classpathLocation; if (fragment.isExternal()) { classpathLocation = fragment.getPath().toFile(); } else { classpathLocation = toFile(fragment.getPath()); }/* w w w . ja v a 2 s . co m*/ if (classpathLocation != null) { classpath.put(classpathLocation, fragment); } } } final JavaProjectInfo projectInfo = new JavaProjectInfo(project, classpath); final Set<File> projectLocations = new HashSet<File>(); final String jarLocation = project.getProject().getPersistentProperty(BinaryProjectPlugin.QNAME_JAR); if (jarLocation != null) { // maven binary project projectLocations.add(new File(jarLocation)); } else { // regular project projectLocations.add(toFile(project.getOutputLocation())); for (IClasspathEntry cpe : project.getRawClasspath()) { if (cpe.getEntryKind() == IClasspathEntry.CPE_SOURCE) { projectLocations.add(toFile(cpe.getOutputLocation())); } } } synchronized (lock) { projects.put(project, projectLocations); for (File projectLocation : projectLocations) { locations.put(projectLocation, projectInfo); } } } }
From source file:com.iw.plugins.spindle.actions.AbstractTapestryProjectAction.java
License:Mozilla Public License
private boolean checkProjectIsOpenAndHasJavaNature(IStructuredSelection selection) { IJavaProject jproject = (IJavaProject) selection.getFirstElement(); IProject project = jproject.getProject(); return project.isOpen(); }
From source file:com.iw.plugins.spindle.actions.AbstractTapestryProjectAction.java
License:Mozilla Public License
protected boolean checkSelection(IStructuredSelection selection) { IJavaProject jproject = (IJavaProject) selection.getFirstElement(); IProject project = jproject.getProject(); try {/*from ww w. j a v a 2s .c om*/ return !project.hasNature(TapestryCore.NATURE_ID); } catch (CoreException e) { return false; } }
From source file:com.iw.plugins.spindle.actions.JumpToApplicationSpecAction.java
License:Mozilla Public License
private IStorage getApplicationStorage(IStructuredSelection selection) { IJavaProject jproject = (IJavaProject) selection.getFirstElement(); IProject project = jproject.getProject(); INamespace namespace = TapestryArtifactManager.getTapestryArtifactManager().getProjectNamespace(project); if (namespace == null) return null; IResourceWorkspaceLocation location = (IResourceWorkspaceLocation) namespace.getSpecificationLocation(); return location.getStorage(); }
From source file:com.iw.plugins.spindle.core.eclipse.TapestryProject.java
License:Mozilla Public License
static public IStatus addTapestryNature(IJavaProject project, boolean forceOrder) { return addTapestryNature(project.getProject(), forceOrder); }