Author: snjeza
Date: 2010-02-09 20:17:46 -0500 (Tue, 09 Feb 2010)
New Revision: 20211
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/FixDialog.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectFix.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizardPage.java
workspace/examples/project-examples-3.1.xml
Log:
https://jira.jboss.org/jira/browse/JBIDE-5700 Simplify project examples update process
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF 2010-02-09
23:52:03 UTC (rev 20210)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF 2010-02-10
01:17:46 UTC (rev 20211)
@@ -25,7 +25,10 @@
org.eclipse.wst.server.core,
org.jboss.tools.seam.core,
org.eclipse.wst.common.project.facet.core,
- org.jboss.tools.common
+ org.jboss.tools.common,
+ org.eclipse.equinox.p2.ui,
+ org.eclipse.equinox.p2.ui.sdk,
+ org.eclipse.equinox.p2.metadata
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Export-Package: org.jboss.tools.project.examples,
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/FixDialog.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/FixDialog.java 2010-02-09
23:52:03 UTC (rev 20210)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/FixDialog.java 2010-02-10
01:17:46 UTC (rev 20211)
@@ -16,9 +16,12 @@
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
@@ -28,14 +31,27 @@
import org.eclipse.swt.widgets.Text;
import org.jboss.tools.project.examples.model.Project;
import org.jboss.tools.project.examples.model.ProjectFix;
+import org.jboss.tools.project.examples.wizard.NewProjectExamplesWizardPage;
public class FixDialog extends Dialog {
+ private static final int FIX_BUTTON = 1;
private TableViewer tableViewer;
private List<ProjectFix> fixes;
+ private Button fixButton;
+ private ProjectFix fix;
+ private NewProjectExamplesWizardPage page;
- public FixDialog(Shell parentShell, IStructuredSelection selection) {
+ public FixDialog(Shell parentShell, NewProjectExamplesWizardPage page) {
super(parentShell);
+ setShellStyle(SWT.CLOSE | SWT.MAX | SWT.TITLE | SWT.BORDER
+ | SWT.MODELESS | SWT.RESIZE | getDefaultOrientation());
+ this.page = page;
+ refresh();
+ }
+
+ private void refresh() {
+ IStructuredSelection selection = page.getSelection();
Iterator iterator = selection.iterator();
fixes = new ArrayList<ProjectFix>();
while (iterator.hasNext()) {
@@ -56,12 +72,12 @@
gd.heightHint = 300;
contents.setLayoutData(gd);
contents.setLayout(new GridLayout());
- getShell().setText("Fixes");
+ getShell().setText("Fixing Requirements");
applyDialogFont(contents);
initializeDialogUnits(area);
Label fixesLabel = new Label(contents, SWT.NULL);
- fixesLabel.setText("Fixes:");
+ fixesLabel.setText("Requirements:");
tableViewer = new TableViewer(contents, SWT.H_SCROLL | SWT.V_SCROLL
| SWT.BORDER | SWT.SINGLE);
Table table = tableViewer.getTable();
@@ -96,10 +112,14 @@
public void selectionChanged(SelectionChangedEvent event) {
description.setText(""); //$NON-NLS-1$
ISelection selection = event.getSelection();
+ fix = null;
+ fixButton.setEnabled(false);
if (selection instanceof IStructuredSelection) {
- Object fix = ((IStructuredSelection) selection).getFirstElement();
- if (fix instanceof ProjectFix) {
- description.setText(((ProjectFix)
fix).getProperties().get(ProjectFix.DESCRIPTION));
+ Object object = ((IStructuredSelection) selection).getFirstElement();
+ if (object instanceof ProjectFix) {
+ fix = (ProjectFix) object;
+ fixButton.setEnabled(fix.isFixable());
+ description.setText(fix.getProperties().get(ProjectFix.DESCRIPTION));
}
}
}
@@ -111,10 +131,36 @@
@Override
protected void createButtonsForButtonBar(Composite parent) {
- createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
+ fixButton = createButton(parent, FIX_BUTTON, "Fix", true);
+ if (fix == null) {
+ fixButton.setEnabled(false);
+ } else {
+ fixButton.setEnabled(fix.isFixable());
+ }
+ fixButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (fix != null) {
+ fix.fix();
+ page.refresh(true);
+ refresh();
+ tableViewer.setInput(fixes);
+ //tableViewer.refresh();
+ }
+ }
+
+ });
+ createButton(parent, IDialogConstants.OK_ID, "Finish",
true);
}
+ @Override
+ protected void buttonPressed(int buttonId) {
+ if (FIX_BUTTON != buttonId) {
+ super.buttonPressed(buttonId);
+ }
+ }
private class FixLabelProvider extends LabelProvider implements
ITableLabelProvider {
@@ -129,7 +175,7 @@
return fix.getType();
}
if (columnIndex == 1) {
- return fix.getProperties().get(ProjectFix.SHORT_DESCRIPTION);
+ return fix.getShortDescription();
}
}
return null;
@@ -153,7 +199,7 @@
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-
+ fixes = (List<ProjectFix>) newInput;
}
}
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectFix.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectFix.java 2010-02-09
23:52:03 UTC (rev 20210)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectFix.java 2010-02-10
01:17:46 UTC (rev 20211)
@@ -3,6 +3,20 @@
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.equinox.internal.p2.ui.sdk.ProvSDKUIActivator;
+import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+import org.eclipse.equinox.internal.provisional.p2.ui.IProvHelpContextIds;
+import
org.eclipse.equinox.internal.provisional.p2.ui.QueryableMetadataRepositoryManager;
+import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.InstallWizard;
+import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.ProvisioningWizardDialog;
+import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
+
public class ProjectFix {
public final static String WTP_RUNTIME = "wtpruntime"; //$NON-NLS-1$
@@ -15,12 +29,26 @@
public final static String ID = "id"; //$NON-NLS-1$
public final static String VERSION = "VERSION"; //$NON-NLS-1$
public final static String DESCRIPTION = "description"; //$NON-NLS-1$
- public final static String SHORT_DESCRIPTION = "short-description";
//$NON-NLS-1$
public final static String ANY = "any"; //$NON-NLS-1$
+ public static final String SEAM_PREFERENCES_ID =
"org.jboss.tools.common.model.ui.seam";
+ public static final String WTP_PREFERENCES_ID =
"org.eclipse.wst.server.ui.runtime.preferencePage";
private String type;
private Map<String,String> properties = new HashMap<String,String>();
+ private static Map<String,String> shortDescriptions = new HashMap<String,
String>();
+ private static Map<String,Boolean> fixableMaps = new HashMap<String,
Boolean>();
+ static {
+ shortDescriptions.put(WTP_RUNTIME, "Missing WTP Runtime");
+ shortDescriptions.put(SEAM_RUNTIME, "Missing Seam Runtime");
+ shortDescriptions.put(PLUGIN_TYPE, "Missing plugin");
+ shortDescriptions.put(DROOLS_RUNTIME, "Missing Drools Runtime");
+ fixableMaps.put(WTP_RUNTIME,true);
+ fixableMaps.put(SEAM_RUNTIME,true);
+ fixableMaps.put(PLUGIN_TYPE,true);
+ fixableMaps.put(DROOLS_RUNTIME,true);
+ }
+
public String getType() {
return type;
}
@@ -34,4 +62,61 @@
this.properties = properties;
}
+ public String getShortDescription() {
+ if (type == null) {
+ return ""; //$NON-NLS-1$
+ }
+ String shortDescription = shortDescriptions.get(type);
+ if (shortDescription == null) {
+ return ""; //$NON-NLS-1$
+ }
+ return shortDescription;
+ }
+
+ public boolean isFixable() {
+ if (type == null) {
+ return false;
+ }
+ Boolean fixable = fixableMaps.get(type);
+ if (fixable == null) {
+ return false;
+ }
+ return fixable;
+ }
+ public void fix() {
+ if (SEAM_RUNTIME.equals(type)) {
+ Shell shell = getShell();
+ PreferenceDialog dialog =
PreferencesUtil.createPreferenceDialogOn(shell,SEAM_PREFERENCES_ID, new String[]
{SEAM_PREFERENCES_ID},null);
+ if (dialog != null) {
+ dialog.open();
+ }
+ }
+ if (WTP_RUNTIME.equals(type)) {
+ Shell shell = getShell();
+ PreferenceDialog dialog =
PreferencesUtil.createPreferenceDialogOn(shell,WTP_PREFERENCES_ID, new String[]
{SEAM_PREFERENCES_ID},null);
+ if (dialog != null) {
+ dialog.open();
+ }
+ }
+ if (PLUGIN_TYPE.equals(type)) {
+ try {
+ final String profileId = ProvSDKUIActivator.getSelfProfileId();
+ final QueryableMetadataRepositoryManager manager = new
QueryableMetadataRepositoryManager(Policy.getDefault().getQueryContext(), false);
+ InstallWizard wizard = new InstallWizard(Policy.getDefault(), profileId, null, null,
manager);
+ WizardDialog dialog = new ProvisioningWizardDialog(getShell(), wizard);
+ dialog.create();
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(),
IProvHelpContextIds.INSTALL_WIZARD);
+ dialog.open();
+ } catch (ProvisionException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ ProjectExamplesActivator.log(e);
+ }
+
+ }
+ }
+ private Shell getShell() {
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ return shell;
+ }
}
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 2010-02-09
23:52:03 UTC (rev 20210)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizardPage.java 2010-02-10
01:17:46 UTC (rev 20211)
@@ -21,6 +21,7 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
@@ -38,6 +39,7 @@
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
@@ -180,38 +182,7 @@
projectURL.setText(""); //$NON-NLS-1$
projectSize.setText(""); //$NON-NLS-1$
}
- boolean canFinish = false;
- Iterator iterator = selection.iterator();
- while (iterator.hasNext()) {
- Object object = iterator.next();
- if (object instanceof Project) {
- canFinish=true;
- Project project = (Project) object;
- if (project.getUnsatisfiedFixes() == null) {
- List<ProjectFix> fixes = project.getFixes();
- List<ProjectFix> unsatisfiedFixes = new ArrayList<ProjectFix>();
- project.setUnsatisfiedFixes(unsatisfiedFixes);
- for (ProjectFix fix:fixes) {
- if (!canFix(project, fix)) {
- unsatisfiedFixes.add(fix);
- }
- }
- }
- if (project.getUnsatisfiedFixes().size() > 0) {
- notesPageBook.showPage(noteComposite);
- noteComposite.setVisible(true);
- noteEmptyComposite.setVisible(false);
- } else {
- notesPageBook.showPage(noteEmptyComposite);
- noteComposite.setVisible(false);
- noteEmptyComposite.setVisible(true);
- }
-
- } else {
- canFinish=false;
- break;
- }
- }
+ boolean canFinish = refresh(false);
setPageComplete(canFinish);
}
@@ -226,36 +197,44 @@
noteEmptyComposite = new Composite( notesPageBook, SWT.NONE );
noteEmptyComposite.setLayout( new GridLayout(1, false));
//notesEmptyComposite.setVisible( false );
- gd=new GridData(GridData.FILL_HORIZONTAL);
+ gd=new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
noteEmptyComposite.setLayoutData(gd);
noteComposite = new Composite(notesPageBook, SWT.NONE);
noteComposite.setLayout(new GridLayout(2,false));
- //notesComposite.setText("Note");
- gd=new GridData(GridData.FILL_HORIZONTAL);
+ gd=new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
noteComposite.setLayoutData(gd);
noteComposite.setVisible(false);
notesPageBook.showPage(noteEmptyComposite);
- Label noteLabel = new Label(noteComposite,SWT.NONE);
- gd=new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- noteLabel.setText("Note:");
+ Composite messageComposite = new Composite(noteComposite, SWT.BORDER);
+ messageComposite.setLayout(new GridLayout(2, false));
+ gd=new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
+
+ messageComposite.setLayoutData(gd);
+
+ Label noteLabel = new Label(messageComposite,SWT.NONE);
+ gd=new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
noteLabel.setLayoutData(gd);
- noteText = new Text(noteComposite, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
+ Image image = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
+ image.setBackground(noteLabel.getBackground());
+ noteLabel.setImage(image);
+
+ noteText = new Text(messageComposite, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
noteText.setText(""); //$NON-NLS-1$
gd = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL |
GridData.GRAB_VERTICAL);
gd.heightHint=50;
+ gd.widthHint = 400;
noteText.setLayoutData(gd);
- noteText.setText("You could face a problem when importing this project example.
For more details click the Details button.");
+ noteText.setText("This example has some requirements that could not be
automatically configured. When importing the example you might see some errors which would
need fixing manually or via Quick Fixes. Click \"Details\" to see more.");
details = new Button(noteComposite, SWT.PUSH);
details.setText("Details...");
details.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- Dialog dialog = new FixDialog(getShell(), getSelection());
+ Dialog dialog = new FixDialog(getShell(), NewProjectExamplesWizardPage.this);
dialog.open();
}
});
@@ -415,4 +394,40 @@
}
return false;
}
+
+ public boolean refresh(boolean force) {
+ boolean canFinish = false;
+ Iterator iterator = selection.iterator();
+ while (iterator.hasNext()) {
+ Object object = iterator.next();
+ if (object instanceof Project) {
+ canFinish=true;
+ Project project = (Project) object;
+ if (force || project.getUnsatisfiedFixes() == null) {
+ List<ProjectFix> fixes = project.getFixes();
+ List<ProjectFix> unsatisfiedFixes = new ArrayList<ProjectFix>();
+ project.setUnsatisfiedFixes(unsatisfiedFixes);
+ for (ProjectFix fix:fixes) {
+ if (!canFix(project, fix)) {
+ unsatisfiedFixes.add(fix);
+ }
+ }
+ }
+ if (project.getUnsatisfiedFixes().size() > 0) {
+ notesPageBook.showPage(noteComposite);
+ noteComposite.setVisible(true);
+ noteEmptyComposite.setVisible(false);
+ } else {
+ notesPageBook.showPage(noteEmptyComposite);
+ noteComposite.setVisible(false);
+ noteEmptyComposite.setVisible(true);
+ }
+
+ } else {
+ canFinish=false;
+ break;
+ }
+ }
+ return canFinish;
+ }
}
Modified: workspace/examples/project-examples-3.1.xml
===================================================================
--- workspace/examples/project-examples-3.1.xml 2010-02-09 23:52:03 UTC (rev 20210)
+++ workspace/examples/project-examples-3.1.xml 2010-02-10 01:17:46 UTC (rev 20211)
@@ -129,21 +129,18 @@
<fixes>
<fix type="wtpruntime">
<property
name="allowed-types">org.jboss.ide.eclipse.as.runtime.eap.50</property>
- <property name="short-description">Missing WTP
Runtime</property>
<property
name="eclipse-projects">booking22,booking22-ejb,booking22-ear</property>
<property name="description">This project example requires the JBoss
EAP 5.0</property>
</fix>
<fix type="seam">
<property name="allowed-versions">2.2.0</property>
- <property name="short-description">Missing Seam
Runtime</property>
<property name="eclipse-projects">booking22</property>
<property name="description">This project example requires Seam
version 2.2.0</property>
</fix>
<fix type="plugin">
<property name="id">org.testng.eclipse</property>
<property name="versions">5.8.0, 5.9.0</property>
- <property name="short-description">Missing TestNG
plugin</property>
<property name="description">The TestNG plugin is required if you
want to run Seam tests. You can install it using the following update site:
http://beust.com/eclipse</property>
</fix>
</fixes>