Author: DartPeng
Date: 2008-11-27 02:27:27 -0500 (Thu, 27 Nov 2008)
New Revision: 12093
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java
Log:
JBIDE-3262
add a link beside by the error message
click the link , a menu will show
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java 2008-11-27
02:28:28 UTC (rev 12092)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java 2008-11-27
07:27:27 UTC (rev 12093)
@@ -89,9 +89,9 @@
private AdapterFactoryEditingDomain editingDomain;
private HashMap userdSelectorString = new HashMap();
-
- private HashMap<String,JavaBeanModel> javaBeanModelCatch = new
HashMap<String,JavaBeanModel>();
+ private HashMap<String, JavaBeanModel> javaBeanModelCatch = new HashMap<String,
JavaBeanModel>();
+
private HashMap<ResourceConfigType, Object> usedResourceConfigMap = new
HashMap<ResourceConfigType, Object>();
private HashMap usedBeanIDMap = new HashMap();
@@ -112,12 +112,14 @@
protected boolean resourceConfigIsUsed(ResourceConfigType config) {
return (usedResourceConfigMap.get(config) != null);
}
-
- protected void registeSourceJavaBeanWithResourceConfig(ResourceConfigType
config,JavaBeanModel model){
+
+ protected void registeSourceJavaBeanWithResourceConfig(
+ ResourceConfigType config, JavaBeanModel model) {
javaBeanModelCatch.put(config.getSelector(), model);
}
-
- protected JavaBeanModel loadJavaBeanWithResourceConfig(ResourceConfigType config){
+
+ protected JavaBeanModel loadJavaBeanWithResourceConfig(
+ ResourceConfigType config) {
return javaBeanModelCatch.get(config.getSelector());
}
@@ -125,8 +127,6 @@
if (!usedResourceConfigMap.containsValue(config))
usedResourceConfigMap.put(config, new Object());
}
-
-
protected CommandStack createCommandStack() {
return new BasicCommandStack();
@@ -329,7 +329,8 @@
.getReferenceEntityModel();
JavaBeanModel currentbean = (JavaBeanModel) target
.getReferenceEntityModel();
- if (sourcebean.getParent() == rootbean || sourcebean == rootbean) {
+ if (sourcebean.getParent() == rootbean
+ || sourcebean.getParent() == null) {
if (!currentbean.isPrimitive()) {
String currentbeanName = currentbean.getName();
if (currentbeanName.length() > 1) {
@@ -374,6 +375,9 @@
AbstractStructuredDataModel sourceModel) {
JavaBeanModel source = (JavaBeanModel) sourceModel
.getReferenceEntityModel();
+ if (source.getParent() == null) {
+ return source.getBeanClassString();
+ }
if (source.getBeanClass().isArray()) {
return source.getName();
}
@@ -575,7 +579,7 @@
.getBindingListFromResourceConfigType(resourceConfig);
if (bindingList == null)
return;
-
+
setResourceConfigUsed(resourceConfig);
registeSourceJavaBeanWithResourceConfig(resourceConfig, source);
for (Iterator<Object> iterator = bindingList.iterator(); iterator
@@ -627,11 +631,13 @@
}
}
}
-
- protected JavaBeanModel findModelWithResourceConfig(ResourceConfigType
config,JavaBeanModel parentModel){
+
+ protected JavaBeanModel findModelWithResourceConfig(
+ ResourceConfigType config, JavaBeanModel parentModel) {
String newSelector = config.getSelector();
- JavaBeanModel model = findTheChildJavaBeanModel(newSelector, parentModel);
- if(model == null){
+ JavaBeanModel model = findTheChildJavaBeanModel(newSelector,
+ parentModel);
+ if (model == null) {
model = loadJavaBeanWithResourceConfig(config);
}
return model;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2008-11-27
02:28:28 UTC (rev 12092)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2008-11-27
07:27:27 UTC (rev 12093)
@@ -97,6 +97,7 @@
import org.eclipse.ui.forms.editor.FormPage;
import org.eclipse.ui.forms.events.HyperlinkEvent;
import org.eclipse.ui.forms.events.IHyperlinkListener;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Hyperlink;
import org.eclipse.ui.forms.widgets.ScrolledForm;
@@ -308,6 +309,9 @@
Composite rootMainControl = form.getBody();
form.setText(Messages
.getString("SmooksGraphicalFormPage.MappingPageFormTitle")); //$NON-NLS-1$
+
+ createErrorMessageLinkGUI(toolkit, rootMainControl);
+
mappingGUISection = this
.createPageSectionHeader(
rootMainControl,
@@ -319,7 +323,8 @@
Composite mainComposite = toolkit.createComposite(mappingGUISection);
mappingGUISection.setClient(mainComposite);
-
+ GridData mapgd = new GridData(GridData.FILL_HORIZONTAL);
+ mappingGUISection.setLayoutData(mapgd);
GridLayout mainLayout = new GridLayout();
mainComposite.setLayout(mainLayout);
@@ -329,12 +334,6 @@
// sashForm.
// sashForm.setSashWidth(1);
- designTimeAnalyzeResultRegion = toolkit.createComposite(sashForm);
- GridLayout ngl = new GridLayout();
- ngl.numColumns = 2;
- ngl.marginWidth = 0;
- designTimeAnalyzeResultRegion.setLayout(ngl);
-
SashForm mappingMainComposite = new SashForm(sashForm, SWT.NONE);
// under the eclipse3.3
// mappingMainComposite.setSashWidth(1);
@@ -462,7 +461,6 @@
toolkit.paintBordersFor(rootMainControl);
form.pack();
- sashForm.setWeights(new int[] { 8, 100 });
if (initSourceTreeViewerProviders()) {
initSourceTreeViewer();
expandSourceConnectionModel();
@@ -476,6 +474,24 @@
initMappingGUIStates();
}
+ protected void createErrorMessageLinkGUI(FormToolkit toolkit,
+ Composite parent) {
+
+ Section secion = this.createPageSectionHeader(parent, Section.TITLE_BAR
+ | Section.DESCRIPTION, "Problems",
+ "Click \"Fix\" link to fix those errors");
+
+ designTimeAnalyzeResultRegion = toolkit.createComposite(secion);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ GridLayout ngl = new GridLayout();
+ ngl.numColumns = 2;
+ ngl.marginWidth = 0;
+ secion.setLayout(new FillLayout());
+ designTimeAnalyzeResultRegion.setLayoutData(gd);
+ designTimeAnalyzeResultRegion.setLayout(ngl);
+ secion.setClient(designTimeAnalyzeResultRegion);
+ }
+
public void refreshAllGUI() {
sourceTreeViewerInputModel = null;
targetTreeViewerInputModel = null;
@@ -1062,8 +1078,7 @@
SmooksConfigurationFileGenerateContext context) {
if (requiredSelectDataSource(typeID)) {
IStructuredDataCreationWizard wizard1 = ViewerInitorStore
- .getInstance().getStructuredDataCreationWizard(
- typeID);
+ .getInstance().getStructuredDataCreationWizard(typeID);
WizardDialog dialog1 = new WizardDialog(getSite().getShell(),
wizard1);
((Wizard) wizard1).setWindowTitle("Target Data Selection");
@@ -1080,8 +1095,7 @@
SmooksConfigurationFileGenerateContext context) {
if (requiredSelectDataSource(typeID)) {
IStructuredDataCreationWizard wizard1 = ViewerInitorStore
- .getInstance().getStructuredDataCreationWizard(
- typeID);
+ .getInstance().getStructuredDataCreationWizard(typeID);
WizardDialog dialog1 = new WizardDialog(getSite().getShell(),
wizard1);
((Wizard) wizard1).setWindowTitle("Source Data Selection");
@@ -1497,9 +1511,18 @@
imageLabel.setImage(SmooksUIActivator.getDefault()
.getImageRegistry().get(
SmooksGraphConstants.IMAGE_ERROR));
- Label notifyLabel = new Label(designTimeAnalyzeResultRegion,
- SWT.NONE);
- Menu menu = new Menu(getSite().getShell(), SWT.POP_UP);
+
+ Composite fixComposite = new Composite(
+ designTimeAnalyzeResultRegion, SWT.NONE);
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 2;
+ gl.marginHeight = 0;
+ gl.marginWidth = 0 ;
+ fixComposite.setLayout(gl);
+ Label notifyLabel = new Label(fixComposite, SWT.NONE);
+ Hyperlink fixLink = getManagedForm().getToolkit()
+ .createHyperlink(fixComposite, "Fix it", SWT.NONE);
+ final Menu menu = new Menu(getSite().getShell(), SWT.POP_UP);
List<ResolveCommand> list = result.getResolveProblem();
for (Iterator<ResolveCommand> iterator2 = list.iterator(); iterator2
.hasNext();) {
@@ -1528,13 +1551,38 @@
item.setText(resolveCommand.getResolveDescription());
item.setImage(resolveCommand.getImage());
}
+ fixLink.addHyperlinkListener(new IHyperlinkListener(){
+
+ public void linkActivated(HyperlinkEvent e) {
+ menu.setLocation(getSite().getShell().getDisplay().getCursorLocation());
+ menu.setVisible(true);
+ }
+
+ public void linkEntered(HyperlinkEvent e) {
+ }
+
+ public void linkExited(HyperlinkEvent e) {
+ }
+
+ });
notifyLabel.setMenu(menu);
GridData nlgd = new GridData(GridData.FILL_HORIZONTAL);
notifyLabel.setLayoutData(nlgd);
+ nlgd = new GridData(GridData.FILL_HORIZONTAL);
+ fixComposite.setLayoutData(nlgd);
notifyLabel.setText(result.getErrorMessage());
-
}
}
+ // GridData gd = new GridData(GridData.FILL_BOTH);
+
+ if (analyzeResultList.size() == 0) {
+ // gd.widthHint = 0;
+ }
+ try {
+ // designTimeAnalyzeResultRegion.setLayoutData(gd);
+ designTimeAnalyzeResultRegion.getParent().getParent().layout();
+ } finally {
+ }
}
protected void updateWarningMessage() {