Author: snjeza
Date: 2011-11-28 14:26:32 -0500 (Mon, 28 Nov 2011)
New Revision: 36711
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/Messages.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/messages.properties
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/AbstractImportProjectExample.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/preferences/ProjectExamplesPreferencePage.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/preferences/ProjectExamplesPreferencesInitializer.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizardPage.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizard.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardFirstPage.java
Log:
JBIDE-10009 project examples should provide way to set the output direcotry
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/Messages.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/Messages.java 2011-11-28
18:45:41 UTC (rev 36710)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/Messages.java 2011-11-28
19:26:32 UTC (rev 36711)
@@ -69,6 +69,7 @@
public static String ProjectExamplesPreferencePage_Show_experimental_sites;
public static String ProjectExamplesPreferencePage_Show_invalid_sites;
public static String ProjectExamplesPreferencePage_Sites;
+ public static String ProjectExamplesPreferencePage_Use_default_workspace_location;
public static String ProjectFix_Missing_Drools_Runtime;
public static String ProjectFix_Missing_plugin;
public static String ProjectFix_Missing_Seam_Runtime;
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java 2011-11-28
18:45:41 UTC (rev 36710)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java 2011-11-28
19:26:32 UTC (rev 36711)
@@ -116,6 +116,8 @@
public static final String MAVEN_ARCHETYPE = "mavenArchetype"; //$NON-NLS-1$
public static final Object PROJECT_EXAMPLES_FAMILY = new Object();
public static final String PROJECT_EXAMPLES_OUTPUT_DIRECTORY =
"projectExamplesOutputDirectory"; //$NON-NLS-1$
+ public static final String PROJECT_EXAMPLES_DEFAULT =
"projectExamplesDefaultLocation"; //$NON-NLS-1$
+ public static final boolean PROJECT_EXAMPLES_DEFAULT_VALUE = true;
private static final String IMPORT_PROJECT_EXAMPLES_EXTENSION_ID =
"org.jboss.tools.project.examples.importProjectExamples"; //$NON-NLS-1$
private static final String NAME = "name"; //$NON-NLS-1$
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/messages.properties
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/messages.properties 2011-11-28
18:45:41 UTC (rev 36710)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/messages.properties 2011-11-28
19:26:32 UTC (rev 36711)
@@ -51,11 +51,12 @@
ProjectExamplesActivator_Waiting=Waiting...
ProjectExamplesPreferencePage_Add=Add
ProjectExamplesPreferencePage_Edit=Edit
-ProjectExamplesPreferencePage_Output_directory=Output directory:
+ProjectExamplesPreferencePage_Output_directory=Output directory
ProjectExamplesPreferencePage_Remove=Remove
ProjectExamplesPreferencePage_Show_experimental_sites=Show experimental sites
ProjectExamplesPreferencePage_Show_invalid_sites=Show invalid sites
ProjectExamplesPreferencePage_Sites=Sites
+ProjectExamplesPreferencePage_Use_default_workspace_location=Use default workspace
location
ProjectFix_Missing_Drools_Runtime=Missing Drools Runtime
ProjectFix_Missing_plugin=Missing plugin
ProjectFix_Missing_Seam_Runtime=Missing Seam Runtime
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/AbstractImportProjectExample.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/AbstractImportProjectExample.java 2011-11-28
18:45:41 UTC (rev 36710)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/AbstractImportProjectExample.java 2011-11-28
19:26:32 UTC (rev 36711)
@@ -51,11 +51,17 @@
@Override
public IPath getLocation() {
- String location =
ProjectExamplesActivator.getDefault().getPreferenceStore().getString(ProjectExamplesActivator.PROJECT_EXAMPLES_OUTPUT_DIRECTORY);
- if (location == null || location.isEmpty()) {
- return Platform.getLocation();
+ boolean isWorkspace = ProjectExamplesActivator.getDefault().getPreferenceStore().
+ getBoolean(ProjectExamplesActivator.PROJECT_EXAMPLES_DEFAULT);
+ if (!isWorkspace) {
+ String location = ProjectExamplesActivator.getDefault().getPreferenceStore().
+ getString(ProjectExamplesActivator.PROJECT_EXAMPLES_OUTPUT_DIRECTORY);
+ if (location == null || location.isEmpty()) {
+ return Platform.getLocation();
+ }
+ return new Path(location);
}
- return new Path(location);
+ return Platform.getLocation();
}
}
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/preferences/ProjectExamplesPreferencePage.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/preferences/ProjectExamplesPreferencePage.java 2011-11-28
18:45:41 UTC (rev 36710)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/preferences/ProjectExamplesPreferencePage.java 2011-11-28
19:26:32 UTC (rev 36711)
@@ -25,6 +25,7 @@
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
@@ -60,48 +61,43 @@
private ProjectExampleSite selectedSite;
private Button showInvalidSites;
private Text outputDirectoryText;
+ private Button isWorkspace;
@Override
protected Control createContents(Composite parent) {
+
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(1, false);
layout.marginWidth = 0;
layout.marginHeight = 0;
composite.setLayout(layout);
- showExperimentalSites = new Button(composite,SWT.CHECK);
- showExperimentalSites.setText(Messages.ProjectExamplesPreferencePage_Show_experimental_sites);
- IPreferenceStore store = ProjectExamplesActivator.getDefault().getPreferenceStore();
- showExperimentalSites.setSelection(store.getBoolean(ProjectExamplesActivator.SHOW_EXPERIMENTAL_SITES));
-
- showInvalidSites = new Button(composite,SWT.CHECK);
- showInvalidSites.setText(Messages.ProjectExamplesPreferencePage_Show_invalid_sites);
- showInvalidSites.setSelection(store.getBoolean(ProjectExamplesActivator.SHOW_INVALID_SITES));
-
- Composite outputDirectoryComposite = new Composite(composite, SWT.NONE);
- layout = new GridLayout(3, false);
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- outputDirectoryComposite.setLayout(layout);
+ Group outputDirectoryGroup = new Group(composite, SWT.NONE);
+ layout = new GridLayout(2, false);
+ outputDirectoryGroup.setLayout(layout);
+ outputDirectoryGroup.setText(Messages.ProjectExamplesPreferencePage_Output_directory);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
- outputDirectoryComposite.setLayoutData(gd);
+ outputDirectoryGroup.setLayoutData(gd);
- Label outputDirectoryLabel = new Label(outputDirectoryComposite,SWT.NONE);
- gd = new GridData(SWT.FILL, SWT.FILL, false, false);
- gd.verticalAlignment = SWT.CENTER;
- outputDirectoryLabel.setLayoutData(gd);
- outputDirectoryLabel.setText(Messages.ProjectExamplesPreferencePage_Output_directory);
+ isWorkspace = new Button(outputDirectoryGroup, SWT.CHECK);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ gd.horizontalSpan = 2;
+ isWorkspace.setLayoutData(gd);
+ isWorkspace.setText(Messages.ProjectExamplesPreferencePage_Use_default_workspace_location);
+ isWorkspace.setSelection(ProjectExamplesActivator.getDefault().getPreferenceStore().getBoolean(ProjectExamplesActivator.PROJECT_EXAMPLES_DEFAULT));
- outputDirectoryText = new Text(outputDirectoryComposite, SWT.SINGLE|SWT.BORDER);
+ outputDirectoryText = new Text(outputDirectoryGroup, SWT.SINGLE|SWT.BORDER);
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
gd.verticalAlignment = SWT.CENTER;
outputDirectoryText.setLayoutData(gd);
+ IPreferenceStore store = ProjectExamplesActivator.getDefault().getPreferenceStore();
String outputDirectoryValue =
store.getString(ProjectExamplesActivator.PROJECT_EXAMPLES_OUTPUT_DIRECTORY);
outputDirectoryText.setText(outputDirectoryValue == null ? "" :
outputDirectoryValue); //$NON-NLS-1$
- Button outputDirectoryBrowse = new Button(outputDirectoryComposite, SWT.PUSH);
+ final Button outputDirectoryBrowse = new Button(outputDirectoryGroup, SWT.PUSH);
outputDirectoryBrowse.setText(Messages.Browse);
- outputDirectoryBrowse.addSelectionListener(new SelectionListener(){
+ outputDirectoryBrowse.addSelectionListener(new SelectionAdapter(){
+ @Override
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.SINGLE);
String value = outputDirectoryText.getText();
@@ -118,11 +114,28 @@
}
- public void widgetDefaultSelected(SelectionEvent e) {
-
+ });
+ enableControls(outputDirectoryBrowse);
+
+ isWorkspace.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ enableControls(outputDirectoryBrowse);
}
+
});
+ showExperimentalSites = new Button(composite,SWT.CHECK);
+ showExperimentalSites.setText(Messages.ProjectExamplesPreferencePage_Show_experimental_sites);
+ showExperimentalSites.setSelection(store.getBoolean(ProjectExamplesActivator.SHOW_EXPERIMENTAL_SITES));
+
+ showInvalidSites = new Button(composite,SWT.CHECK);
+ showInvalidSites.setText(Messages.ProjectExamplesPreferencePage_Show_invalid_sites);
+ showInvalidSites.setSelection(store.getBoolean(ProjectExamplesActivator.SHOW_INVALID_SITES));
+
+
+
Group sitesGroup = new Group(composite,SWT.NONE);
sitesGroup.setText(Messages.ProjectExamplesPreferencePage_Sites);
GridLayout gl = new GridLayout(2,false);
@@ -165,9 +178,7 @@
viewer.refresh();
}
}
- }
-
-
+ }
});
final Button editButton = new Button(buttonComposite, SWT.PUSH);
editButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
@@ -240,6 +251,11 @@
return composite;
}
+ protected void enableControls(Button outputDirectoryBrowse) {
+ outputDirectoryText.setEnabled(!isWorkspace.getSelection());
+ outputDirectoryBrowse.setEnabled(!isWorkspace.getSelection());
+ }
+
public void init(IWorkbench workbench) {
}
@@ -247,6 +263,7 @@
protected void performDefaults() {
showExperimentalSites.setSelection(ProjectExamplesActivator.SHOW_EXPERIMENTAL_SITES_VALUE);
showInvalidSites.setSelection(ProjectExamplesActivator.SHOW_INVALID_SITES_VALUE);
+ isWorkspace.setSelection(ProjectExamplesActivator.PROJECT_EXAMPLES_DEFAULT_VALUE);
outputDirectoryText.setText(""); //$NON-NLS-1$
sites.getUserSites().clear();
storePreferences();
@@ -263,6 +280,7 @@
IPreferenceStore store = ProjectExamplesActivator.getDefault().getPreferenceStore();
store.setValue(ProjectExamplesActivator.SHOW_EXPERIMENTAL_SITES,
showExperimentalSites.getSelection());
store.setValue(ProjectExamplesActivator.SHOW_INVALID_SITES,
showInvalidSites.getSelection());
+ store.setValue(ProjectExamplesActivator.PROJECT_EXAMPLES_DEFAULT,
isWorkspace.getSelection());
String value = outputDirectoryText.getText();
if (!value.isEmpty()) {
store.setValue(ProjectExamplesActivator.PROJECT_EXAMPLES_OUTPUT_DIRECTORY, value);
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/preferences/ProjectExamplesPreferencesInitializer.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/preferences/ProjectExamplesPreferencesInitializer.java 2011-11-28
18:45:41 UTC (rev 36710)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/preferences/ProjectExamplesPreferencesInitializer.java 2011-11-28
19:26:32 UTC (rev 36711)
@@ -35,6 +35,9 @@
node.putBoolean(
ProjectExamplesActivator.SHOW_INVALID_SITES,
ProjectExamplesActivator.SHOW_INVALID_SITES_VALUE);
+ node.putBoolean(
+ ProjectExamplesActivator.PROJECT_EXAMPLES_DEFAULT,
+ ProjectExamplesActivator.PROJECT_EXAMPLES_DEFAULT_VALUE);
}
}
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java 2011-11-28
18:45:41 UTC (rev 36710)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java 2011-11-28
19:26:32 UTC (rev 36711)
@@ -45,6 +45,7 @@
@Override
public boolean performFinish() {
+ page.finishPage();
final List<Project> selectedProjects = new ArrayList<Project>();
if (page.getSelection() == null || page.getSelection().size() <= 0) {
return false;
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizardPage.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizardPage.java 2011-11-28
18:45:41 UTC (rev 36710)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizardPage.java 2011-11-28
19:26:32 UTC (rev 36711)
@@ -19,6 +19,7 @@
import java.util.TreeSet;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
@@ -36,6 +37,8 @@
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.GC;
@@ -47,7 +50,9 @@
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Monitor;
import org.eclipse.swt.widgets.Shell;
@@ -72,7 +77,7 @@
*/
public class NewProjectExamplesWizardPage extends WizardPage {
- private static final int DEFAULT_HEIGHT = 400;
+ private static final int DEFAULT_HEIGHT = 430;
private static final int DEFAULT_WIDTH = 600;
private IStructuredSelection selection;
private Button showQuickFixButton;
@@ -84,6 +89,8 @@
private Composite noteComposite;
private List<Category> categories;
private Text descriptionText;
+ private Button isWorkspace;
+ private Text outputDirectoryText;
public NewProjectExamplesWizardPage() {
super("org.jboss.tools.project.examples"); //$NON-NLS-1$
@@ -93,14 +100,65 @@
}
public void createControl(Composite parent) {
-
Composite composite = new Composite(parent,SWT.NONE);
composite.setLayout(new GridLayout(1,false));
-
GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false);
-
composite.setLayoutData(gd);
+ Group outputDirectoryGroup = new Group(composite, SWT.NONE);
+ GridLayout layout = new GridLayout(2, false);
+ outputDirectoryGroup.setLayout(layout);
+ outputDirectoryGroup.setText(Messages.ProjectExamplesPreferencePage_Output_directory);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ outputDirectoryGroup.setLayoutData(gd);
+
+ isWorkspace = new Button(outputDirectoryGroup, SWT.CHECK);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ gd.horizontalSpan = 2;
+ isWorkspace.setLayoutData(gd);
+ isWorkspace.setText(Messages.ProjectExamplesPreferencePage_Use_default_workspace_location);
+ isWorkspace.setSelection(ProjectExamplesActivator.getDefault().getPreferenceStore().getBoolean(ProjectExamplesActivator.PROJECT_EXAMPLES_DEFAULT));
+
+ outputDirectoryText = new Text(outputDirectoryGroup, SWT.SINGLE|SWT.BORDER);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ gd.verticalAlignment = SWT.CENTER;
+ outputDirectoryText.setLayoutData(gd);
+ final IPreferenceStore store =
ProjectExamplesActivator.getDefault().getPreferenceStore();
+ String outputDirectoryValue =
store.getString(ProjectExamplesActivator.PROJECT_EXAMPLES_OUTPUT_DIRECTORY);
+ outputDirectoryText.setText(outputDirectoryValue == null ? "" :
outputDirectoryValue); //$NON-NLS-1$
+ final Button outputDirectoryBrowse = new Button(outputDirectoryGroup, SWT.PUSH);
+ outputDirectoryBrowse.setText(Messages.Browse);
+ outputDirectoryBrowse.addSelectionListener(new SelectionAdapter(){
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.SINGLE);
+ String value = outputDirectoryText.getText();
+ if (value.trim().length() == 0) {
+ value = Platform.getLocation().toOSString();
+ }
+ dialog.setFilterPath(value);
+
+ String result = dialog.open();
+ if (result == null || result.trim().length() == 0) {
+ return;
+ }
+ outputDirectoryText.setText(result);
+
+ }
+
+ });
+ enableControls(outputDirectoryBrowse);
+
+ isWorkspace.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ enableControls(outputDirectoryBrowse);
+ }
+
+ });
+
Composite siteComposite = new Composite(composite,SWT.NONE);
GridLayout gridLayout = new GridLayout(2,false);
gridLayout.marginHeight = 0;
@@ -114,7 +172,6 @@
gd.horizontalSpan = 2;
button.setLayoutData(gd);
button.setText(Messages.ProjectExamplesPreferencePage_Show_experimental_sites);
- IPreferenceStore store = ProjectExamplesActivator.getDefault().getPreferenceStore();
button.setSelection(store.getBoolean(ProjectExamplesActivator.SHOW_EXPERIMENTAL_SITES));
new Label(siteComposite,SWT.NONE).setText(Messages.NewProjectExamplesWizardPage_Site);
@@ -304,6 +361,11 @@
refresh(viewer, true);
siteCombo.setText(ProjectExamplesActivator.ALL_SITES);
}
+
+ protected void enableControls(Button outputDirectoryBrowse) {
+ outputDirectoryText.setEnabled(!isWorkspace.getSelection());
+ outputDirectoryBrowse.setEnabled(!isWorkspace.getSelection());
+ }
private void configureSizeAndLocation() {
Shell shell = getContainer().getShell();
@@ -575,4 +637,12 @@
noteText.setText(Messages.NewProjectExamplesWizardPage_Note);
details.setEnabled(true);
}
+
+ public void finishPage() {
+ final IPreferenceStore store =
ProjectExamplesActivator.getDefault().getPreferenceStore();
+ store.setValue(ProjectExamplesActivator.PROJECT_EXAMPLES_DEFAULT,
isWorkspace.getSelection());
+ if (outputDirectoryText.getText().trim().length() > 0) {
+ store.setValue(ProjectExamplesActivator.PROJECT_EXAMPLES_OUTPUT_DIRECTORY,
outputDirectoryText.getText());
+ }
+ }
}
Modified:
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizard.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizard.java 2011-11-28
18:45:41 UTC (rev 36710)
+++
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizard.java 2011-11-28
19:26:32 UTC (rev 36711)
@@ -42,10 +42,12 @@
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkingSet;
+import org.jboss.tools.maven.project.examples.ImportMavenArchetypeProjectExample;
import org.jboss.tools.maven.project.examples.MavenProjectExamplesActivator;
import org.jboss.tools.project.examples.ProjectExamplesActivator;
import org.jboss.tools.project.examples.model.Project;
@@ -58,7 +60,6 @@
public class ArchetypeExamplesWizard extends Wizard implements INewWizard {
private Project projectDescription;
- //private File location;
private ProjectImportConfiguration configuration;
private ArchetypeExamplesWizardFirstPage simplePage;
private ArchetypeExamplesWizardPage wizardPage;
@@ -66,13 +67,11 @@
private String projectName;
private String artifactId;
-
public ArchetypeExamplesWizard(File location, Project projectDescription) {
super();
setWindowTitle("New JBoss project");
setDefaultPageImageDescriptor(MavenImages.WIZ_NEW_PROJECT);
setNeedsProgressMonitor(true);
- //this.location = location;
this.projectDescription = projectDescription;
}
@@ -167,7 +166,11 @@
configuration.getResolverConfiguration().setActiveProfiles(profiles);
}
simplePage = new ArchetypeExamplesWizardFirstPage(configuration, projectDescription,
workingSets);
- addPage(simplePage);
+ addPage(simplePage);
+ String location =
ProjectExamplesActivator.getDefault().getPreferenceStore().getString(ProjectExamplesActivator.PROJECT_EXAMPLES_OUTPUT_DIRECTORY);
+ if (location != null && location.trim().length() > 0) {
+ simplePage.setLocationPath(new Path(location));
+ }
wizardPage = new ArchetypeExamplesWizardPage(configuration, projectDescription);
wizardPage.setPageComplete(true);//We want to enable the finish button early
addPage(wizardPage);
@@ -210,4 +213,10 @@
public String getArtifactId() {
return artifactId;
}
+
+ @Override
+ public void createPageControls(Composite pageContainer) {
+ super.createPageControls(pageContainer);
+
simplePage.setUseDefaultWorkspaceLocation(ProjectExamplesActivator.getDefault().getPreferenceStore().getBoolean(ProjectExamplesActivator.PROJECT_EXAMPLES_DEFAULT));
+ }
}
Modified:
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardFirstPage.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardFirstPage.java 2011-11-28
18:45:41 UTC (rev 36710)
+++
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardFirstPage.java 2011-11-28
19:26:32 UTC (rev 36711)
@@ -10,6 +10,7 @@
************************************************************************************/
package org.jboss.tools.maven.project.examples.wizard;
+import java.lang.reflect.Field;
import java.net.URL;
import java.util.Collections;
import java.util.LinkedHashMap;
@@ -37,8 +38,10 @@
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.ui.IWorkingSet;
@@ -49,6 +52,7 @@
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.internal.facets.FacetUtil;
import org.jboss.ide.eclipse.as.core.util.RuntimeUtils;
+import org.jboss.tools.maven.project.examples.MavenProjectExamplesActivator;
import org.jboss.tools.maven.project.examples.Messages;
import org.jboss.tools.project.examples.model.Project;
@@ -326,4 +330,19 @@
this.propertyModifyListener = propertyModifyListener;
}
+ public void setUseDefaultWorkspaceLocation(boolean value) {
+ Class clazz = MavenProjectWizardLocationPage.class;
+ try {
+ Field field = clazz.getDeclaredField("useDefaultWorkspaceLocationButton");
//$NON-NLS-1$
+ field.setAccessible(true);
+ Object useDefaultWorkspaceLocation = field.get(this);
+ if (useDefaultWorkspaceLocation instanceof Button) {
+ Button useDefaultWorkspaceLocationButton = (Button) useDefaultWorkspaceLocation;
+ useDefaultWorkspaceLocationButton.setSelection(value);
+ useDefaultWorkspaceLocationButton.notifyListeners(SWT.Selection, new Event());
+ }
+ } catch (Exception e) {
+ MavenProjectExamplesActivator.log(e);
+ }
+ }
}