/******************************************************************************* * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.ui.wizards; import java.io.File; import java.io.IOException; import java.net.URI; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Observable; import java.util.Observer; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.DirectoryDialog; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Link; import org.eclipse.core.filesystem.URIUtil; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ITreeSelection; import org.eclipse.jface.viewers.TreePath; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkingSet; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.PreferencesUtil; import org.eclipse.ui.dialogs.WorkingSetConfigurationBlock; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.internal.corext.util.JavaModelUtil; import org.eclipse.jdt.internal.corext.util.Messages; import org.eclipse.jdt.launching.IVMInstall; import org.eclipse.jdt.launching.IVMInstall2; import org.eclipse.jdt.launching.IVMInstallType; import org.eclipse.jdt.launching.JavaRuntime; import org.eclipse.jdt.launching.VMStandin; import org.eclipse.jdt.launching.environments.IExecutionEnvironment; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart; import org.eclipse.jdt.internal.ui.preferences.CompliancePreferencePage; import org.eclipse.jdt.internal.ui.preferences.NewJavaProjectPreferencePage; import org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage; import org.eclipse.jdt.internal.ui.util.CoreUtility; import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; import org.eclipse.jdt.internal.ui.wizards.ClassPathDetector; import org.eclipse.jdt.internal.ui.wizards.JavaProjectWizard; import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages; import org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathSupport; import org.eclipse.jdt.internal.ui.wizards.dialogfields.ComboDialogField; import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField; import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener; import org.eclipse.jdt.internal.ui.wizards.dialogfields.IStringButtonAdapter; import org.eclipse.jdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField; import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringButtonDialogField; import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringDialogField; import org.eclipse.jdt.internal.ui.workingsets.IWorkingSetIDs; /** * The first page of the New Java Project wizard. This page is typically used in combination with * {@link NewJavaProjectWizardPageTwo}. Clients can extend this page to modify the UI: Add, remove * or reorder sections. * *
* Clients may instantiate or subclass. *
* * @since 3.4 */ public class NewJavaProjectWizardPageOne extends WizardPage { /** * Request a project name. Fires an event whenever the text field is * changed, regardless of its content. */ public final class NameGroup extends Observable implements IDialogFieldListener { public final StringDialogField fNameField; public NameGroup() { // text field for project name fNameField= new StringDialogField(); fNameField.generated_3193238318253913111(this); } public Control createControl(Composite composite) { Composite nameComposite= new Composite(composite, SWT.NONE); nameComposite.setFont(composite.getFont()); return fNameField.generated_253327009741664144(nameComposite); } protected void fireEvent() { setChanged(); notifyObservers(); } public String getName() { return fNameField.getText().trim(); } public void postSetFocus() { fNameField.postSetFocusOnDialogField(getShell().getDisplay()); } public void setName(String name) { fNameField.setText(name); } /* (non-Javadoc) * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener#dialogFieldChanged(org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField) */ public void dialogFieldChanged(DialogField field) { fireEvent(); } } /** * Request a location. Fires an event whenever the checkbox or the location * field is changed, regardless of whether the change originates from the * user or has been invoked programmatically. */ public final class LocationGroup extends Observable implements Observer, IStringButtonAdapter, IDialogFieldListener { public final SelectionButtonDialogField fUseDefaults; public final StringButtonDialogField fLocation; public String fPreviousExternalLocation; private static final String DIALOGSTORE_LAST_EXTERNAL_LOC= JavaUI.ID_PLUGIN + ".last.external.project"; //$NON-NLS-1$ public LocationGroup() { fUseDefaults= new SelectionButtonDialogField(SWT.CHECK); fUseDefaults.setDialogFieldListener(this); fUseDefaults.setLabelText(NewWizardMessages.NewJavaProjectWizardPageOne_LocationGroup_location_desc); fLocation= new StringButtonDialogField(this); fLocation.generated_5234504517016112488(this); fPreviousExternalLocation= ""; //$NON-NLS-1$ } public Control createControl(Composite composite) { final int numColumns= 4; final Composite locationComposite= new Composite(composite, SWT.NONE); fLocation.generated_643901326608760342(this, numColumns, locationComposite); return locationComposite; } protected void fireEvent() { setChanged(); notifyObservers(); } protected String getDefaultPath(String name) { final IPath path= Platform.getLocation().append(name); return path.toOSString(); } /* (non-Javadoc) * @see java.util.Observer#update(java.util.Observable, java.lang.Object) */ public void update(Observable o, Object arg) { if (isUseDefaultSelected()) { fLocation.setText(getDefaultPath(fNameGroup.getName())); } fireEvent(); } public IPath getLocation() { if (isUseDefaultSelected()) { return Platform.getLocation(); } return Path.fromOSString(fLocation.getText().trim()); } public boolean isUseDefaultSelected() { return fUseDefaults.isSelected(); } public void setLocation(IPath path) { fUseDefaults.setSelection(path == null); if (path != null) { fLocation.setText(path.toOSString()); } else { fLocation.setText(getDefaultPath(fNameGroup.getName())); } fireEvent(); } /* (non-Javadoc) * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IStringButtonAdapter#changeControlPressed(org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField) */ public void changeControlPressed(DialogField field) { final DirectoryDialog dialog= new DirectoryDialog(getShell()); dialog.setMessage(NewWizardMessages.NewJavaProjectWizardPageOne_directory_message); String directoryName = fLocation.getText().trim(); if (directoryName.length() == 0) { String prevLocation= JavaPlugin.getDefault().getDialogSettings().get(DIALOGSTORE_LAST_EXTERNAL_LOC); if (prevLocation != null) { directoryName= prevLocation; } } if (directoryName.length() > 0) { final File path = new File(directoryName); if (path.exists()) dialog.setFilterPath(directoryName); } final String selectedDirectory = dialog.open(); if (selectedDirectory != null) { String oldDirectory= fLocation.generated_6444432378694638790(selectedDirectory); String lastSegment= new Path(selectedDirectory).lastSegment(); if (lastSegment != null && (fNameGroup.getName().length() == 0 || fNameGroup.getName().equals(oldDirectory))) { fNameGroup.setName(lastSegment); } JavaPlugin.getDefault().getDialogSettings().put(DIALOGSTORE_LAST_EXTERNAL_LOC, selectedDirectory); } } /* (non-Javadoc) * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener#dialogFieldChanged(org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField) */ public void dialogFieldChanged(DialogField field) { if (field == fUseDefaults) { final boolean checked= fUseDefaults.isSelected(); if (checked) { fPreviousExternalLocation= fLocation.getText(); fLocation.setText(getDefaultPath(fNameGroup.getName())); fLocation.setEnabled(false); } else { fLocation.generated_3726504999918786352(this); } } fireEvent(); } public URI generated_4065803390293803522() { if (isUseDefaultSelected()) { return null; } return URIUtil.toURI(getLocation()); } } /** * Request a project layout. */ public final class LayoutGroup implements Observer, SelectionListener { public final SelectionButtonDialogField fStdRadio; public final SelectionButtonDialogField fSrcBinRadio; public Group fGroup; public Link fPreferenceLink; public LayoutGroup() { fStdRadio= new SelectionButtonDialogField(SWT.RADIO); fStdRadio.setLabelText(NewWizardMessages.NewJavaProjectWizardPageOne_LayoutGroup_option_oneFolder); fSrcBinRadio= new SelectionButtonDialogField(SWT.RADIO); fSrcBinRadio.generated_2986520533270641386(this); } public Control createContent(Composite composite) { fGroup= new Group(composite, SWT.NONE); fGroup.setFont(composite.getFont()); fGroup.setLayout(initGridLayout(new GridLayout(3, false), true)); fGroup.setText(NewWizardMessages.NewJavaProjectWizardPageOne_LayoutGroup_title); return fStdRadio.generated_8796833943613112164(this); } /* (non-Javadoc) * @see java.util.Observer#update(java.util.Observable, java.lang.Object) */ public void update(Observable o, Object arg) { updateEnableState(); } public void updateEnableState() { if (fDetectGroup == null) return; final boolean detect= fDetectGroup.mustDetect(); fStdRadio.setEnabled(!detect); fSrcBinRadio.setEnabled(!detect); if (fPreferenceLink != null) { fPreferenceLink.setEnabled(!detect); } if (fGroup != null) { fGroup.setEnabled(!detect); } } /** * Returntrue
if the user specified to create 'source' and 'bin' folders.
*
* @return returns true
if the user specified to create 'source' and 'bin' folders.
*/
public boolean isSrcBin() {
return fSrcBinRadio.isSelected();
}
/* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
/* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
*/
public void widgetDefaultSelected(SelectionEvent e) {
String id= NewJavaProjectPreferencePage.ID;
PreferencesUtil.createPreferenceDialogOn(getShell(), id, new String[] { id }, null).open();
fDetectGroup.handlePossibleJVMChange();
fJREGroup.handlePossibleJVMChange();
}
}
public final class JREGroup implements Observer, SelectionListener, IDialogFieldListener {
private static final String LAST_SELECTED_EE_SETTINGS_KEY= JavaUI.ID_PLUGIN + ".last.selected.execution.enviroment"; //$NON-NLS-1$
private static final String LAST_SELECTED_JRE_SETTINGS_KEY= JavaUI.ID_PLUGIN + ".last.selected.project.jre"; //$NON-NLS-1$
// private static final String LAST_SELECTED_JRE_KIND= JavaUI.ID_PLUGIN + ".last.selected.jre.kind"; // used before EE became default
public static final String LAST_SELECTED_JRE_KIND2= JavaUI.ID_PLUGIN + ".last.selected.jre.kind2"; //$NON-NLS-1$
private static final int DEFAULT_JRE= 0;
public static final int PROJECT_JRE= 1;
public static final int EE_JRE= 2;
public final SelectionButtonDialogField fUseDefaultJRE;
public final SelectionButtonDialogField fUseProjectJRE;
public final SelectionButtonDialogField fUseEEJRE;
public final ComboDialogField fJRECombo;
public final ComboDialogField fEECombo;
private Group fGroup;
public Link fPreferenceLink;
public IVMInstall[] fInstalledJVMs;
public String[] fJRECompliance;
public IExecutionEnvironment[] fInstalledEEs;
public String[] fEECompliance;
public JREGroup() {
fUseDefaultJRE= new SelectionButtonDialogField(SWT.RADIO);
fUseDefaultJRE.setLabelText(getDefaultJVMLabel());
fUseProjectJRE= new SelectionButtonDialogField(SWT.RADIO);
fUseProjectJRE.setLabelText(NewWizardMessages.NewJavaProjectWizardPageOne_JREGroup_specific_compliance);
fJRECombo= new ComboDialogField(SWT.READ_ONLY);
fillInstalledJREs(fJRECombo);
fJRECombo.setDialogFieldListener(this);
fUseEEJRE= new SelectionButtonDialogField(SWT.RADIO);
fUseEEJRE.setLabelText(NewWizardMessages.NewJavaProjectWizardPageOne_JREGroup_specific_EE);
fEECombo= new ComboDialogField(SWT.READ_ONLY);
fillExecutionEnvironments(fEECombo);
fEECombo.setDialogFieldListener(this);
switch (getLastSelectedJREKind()) {
case DEFAULT_JRE:
fUseDefaultJRE.setSelection(true);
break;
case PROJECT_JRE:
fUseProjectJRE.setSelection(true);
break;
case EE_JRE:
fUseEEJRE.setSelection(true);
break;
}
fUseProjectJRE.generated_1822827867514341499(this);
fUseEEJRE.setDialogFieldListener(this);
}
public Control createControl(Composite composite) {
fGroup= new Group(composite, SWT.NONE);
fGroup.setFont(composite.getFont());
fGroup.setLayout(initGridLayout(new GridLayout(2, false), true));
fGroup.setText(NewWizardMessages.NewJavaProjectWizardPageOne_JREGroup_title);
fUseEEJRE.doFillIntoGrid(fGroup, 1);
Combo eeComboControl= fEECombo.getComboControl(fGroup);
eeComboControl.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
fUseProjectJRE.doFillIntoGrid(fGroup, 1);
Combo comboControl= fJRECombo.getComboControl(fGroup);
comboControl.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
fUseDefaultJRE.doFillIntoGrid(fGroup, 1);
fPreferenceLink= new Link(fGroup, SWT.NONE);
fPreferenceLink.setFont(fGroup.getFont());
fPreferenceLink.setText(NewWizardMessages.NewJavaProjectWizardPageOne_JREGroup_link_description);
fPreferenceLink.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
fPreferenceLink.addSelectionListener(this);
updateEnableState();
return fGroup;
}
private void fillInstalledJREs(ComboDialogField comboField) {
String selectedItem= getLastSelectedJRE();
int selectionIndex= -1;
comboField.generated_14267488333256409(JREGroup.this, selectedItem);
}
private void fillExecutionEnvironments(ComboDialogField comboField) {
comboField.generated_5411689368033140336(JREGroup.this);
}
public IVMInstall[] getWorkspaceJREs() {
Listnull
*/
public void init(IStructuredSelection selection, IWorkbenchPart activePart) {
setWorkingSets(getSelectedWorkingSet(selection, activePart));
}
private void initializeDefaultVM() {
JavaRuntime.getDefaultVMInstall();
}
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
public void createControl(Composite parent) {
initializeDialogUnits(parent);
final Composite composite= new Composite(parent, SWT.NULL);
composite.setFont(parent.getFont());
composite.setLayout(initGridLayout(new GridLayout(1, false), true));
composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
// create UI elements
Control nameControl= createNameControl(composite);
nameControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Control locationControl= createLocationControl(composite);
locationControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Control jreControl= createJRESelectionControl(composite);
jreControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Control layoutControl= createProjectLayoutControl(composite);
layoutControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Control workingSetControl= createWorkingSetControl(composite);
workingSetControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Control infoControl= createInfoControl(composite);
infoControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
setControl(composite);
}
@Override
protected void setControl(Control newControl) {
Dialog.applyDialogFont(newControl);
PlatformUI.getWorkbench().getHelpSystem().setHelp(newControl, IJavaHelpContextIds.NEW_JAVAPROJECT_WIZARD_PAGE);
super.setControl(newControl);
}
/**
* Creates the controls for the name field.
*
* @param composite the parent composite
* @return the created control
*/
protected Control createNameControl(Composite composite) {
return fNameGroup.createControl(composite);
}
/**
* Creates the controls for the location field.
*
* @param composite the parent composite
* @return the created control
*/
protected Control createLocationControl(Composite composite) {
return fLocationGroup.createControl(composite);
}
/**
* Creates the controls for the JRE selection
*
* @param composite the parent composite
* @return the created control
*/
protected Control createJRESelectionControl(Composite composite) {
return fJREGroup.createControl(composite);
}
/**
* Creates the controls for the project layout selection.
*
* @param composite the parent composite
* @return the created control
*/
protected Control createProjectLayoutControl(Composite composite) {
return fLayoutGroup.createContent(composite);
}
/**
* Creates the controls for the working set selection.
*
* @param composite the parent composite
* @return the created control
*/
protected Control createWorkingSetControl(Composite composite) {
return fWorkingSetGroup.createControl(composite);
}
/**
* Creates the controls for the info section.
*
* @param composite the parent composite
* @return the created control
*/
protected Control createInfoControl(Composite composite) {
return fDetectGroup.createControl(composite);
}
/**
* Gets a project name for the new project.
*
* @return the new project resource handle
*/
public String getProjectName() {
return fNameGroup.getName();
}
/**
* Sets the name of the new project
*
* @param name the new name
*/
public void setProjectName(String name) {
if (name == null)
throw new IllegalArgumentException();
fNameGroup.setName(name);
}
/**
* Returns the current project location path as entered by the user, or null
* if the project should be created in the workspace.
* @return the project location path or its anticipated initial value.
*/
public URI getProjectLocationURI() {
return fLocationGroup.generated_4065803390293803522();
}
/**
* Sets the project location of the new project or null
if the project
* should be created in the workspace
*
* @param uri the new project location
*/
public void setProjectLocationURI(URI uri) {
IPath path= uri != null ? URIUtil.toPath(uri) : null;
fLocationGroup.setLocation(path);
}
/**
* Returns the compiler compliance to be used for the project, or null
to use the workspace
* compiler compliance.
*
* @return compiler compliance to be used for the project or null
*/
public String getCompilerCompliance() {
return fJREGroup.getSelectedCompilerCompliance();
}
/**
* Returns the default class path entries to be added on new projects. By default this is the JRE container as
* selected by the user.
*
* @return returns the default class path entries
*/
public IClasspathEntry[] getDefaultClasspathEntries() {
IPath newPath= fJREGroup.getJREContainerPath();
if (newPath != null) {
return new IClasspathEntry[] { JavaCore.newContainerEntry(newPath) };
}
return PreferenceConstants.getDefaultJRELibrary();
}
/**
* Returns the source class path entries to be added on new projects.
* The underlying resources may not exist. All entries that are returned must be of kind
* {@link IClasspathEntry#CPE_SOURCE}.
*
* @return returns the source class path entries for the new project
*/
public IClasspathEntry[] getSourceClasspathEntries() {
IPath sourceFolderPath= new Path(getProjectName()).makeAbsolute();
if (fLayoutGroup.isSrcBin()) {
IPath srcPath= new Path(PreferenceConstants.getPreferenceStore().getString(PreferenceConstants.SRCBIN_SRCNAME));
if (srcPath.segmentCount() > 0) {
sourceFolderPath= sourceFolderPath.append(srcPath);
}
}
return new IClasspathEntry[] { JavaCore.newSourceEntry(sourceFolderPath) };
}
/**
* Returns the source class path entries to be added on new projects.
* The underlying resource may not exist.
*
* @return returns the default class path entries
*/
public IPath getOutputLocation() {
IPath outputLocationPath= new Path(getProjectName()).makeAbsolute();
if (fLayoutGroup.isSrcBin()) {
IPath binPath= new Path(PreferenceConstants.getPreferenceStore().getString(PreferenceConstants.SRCBIN_BINNAME));
if (binPath.segmentCount() > 0) {
outputLocationPath= outputLocationPath.append(binPath);
}
}
return outputLocationPath;
}
/**
* Returns the working sets to which the new project should be added.
*
* @return the selected working sets to which the new project should be added
*/
public IWorkingSet[] getWorkingSets() {
return fWorkingSetGroup.getSelectedWorkingSets();
}
/**
* Sets the working sets to which the new project should be added.
*
* @param workingSets the initial selected working sets
*/
public void setWorkingSets(IWorkingSet[] workingSets) {
if (workingSets == null) {
throw new IllegalArgumentException();
}
fWorkingSetGroup.setWorkingSets(workingSets);
}
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
*/
@Override
public void setVisible(boolean visible) {
super.setVisible(visible);
if (visible) {
fNameGroup.postSetFocus();
}
}
private GridLayout initGridLayout(GridLayout layout, boolean margins) {
layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
if (margins) {
layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
} else {
layout.marginWidth= 0;
layout.marginHeight= 0;
}
return layout;
}
public static final IWorkingSet[] EMPTY_WORKING_SET_ARRAY = new IWorkingSet[0];
private IWorkingSet[] getSelectedWorkingSet(IStructuredSelection selection, IWorkbenchPart activePart) {
IWorkingSet[] selected= getSelectedWorkingSet(selection);
if (selected != null && selected.length > 0) {
for (int i= 0; i < selected.length; i++) {
if (!isValidWorkingSet(selected[i]))
return EMPTY_WORKING_SET_ARRAY;
}
return selected;
}
if (!(activePart instanceof PackageExplorerPart))
return EMPTY_WORKING_SET_ARRAY;
PackageExplorerPart explorerPart= (PackageExplorerPart) activePart;
return explorerPart.generated_8214304763819303281();
}
private IWorkingSet[] getSelectedWorkingSet(IStructuredSelection selection) {
if (!(selection instanceof ITreeSelection))
return EMPTY_WORKING_SET_ARRAY;
ITreeSelection treeSelection= (ITreeSelection) selection;
if (treeSelection.isEmpty())
return EMPTY_WORKING_SET_ARRAY;
List> elements= treeSelection.toList();
if (elements.size() == 1) {
Object element= elements.get(0);
TreePath[] paths= treeSelection.getPathsFor(element);
if (paths.length != 1)
return EMPTY_WORKING_SET_ARRAY;
TreePath path= paths[0];
if (path.getSegmentCount() == 0)
return EMPTY_WORKING_SET_ARRAY;
Object candidate= path.getSegment(0);
if (!(candidate instanceof IWorkingSet))
return EMPTY_WORKING_SET_ARRAY;
IWorkingSet workingSetCandidate= (IWorkingSet) candidate;
if (isValidWorkingSet(workingSetCandidate))
return new IWorkingSet[] { workingSetCandidate };
return EMPTY_WORKING_SET_ARRAY;
}
ArrayList