]
Kabir Khan closed JBAOP-262.
----------------------------
Resolution: Duplicate Issue
Assignee: Kabir Khan
I believe this is a duplicate of
prepare leads to NullPointerException in _getInstanceAdvisor
------------------------------------------------------------
Key: JBAOP-262
URL:
http://jira.jboss.com/jira/browse/JBAOP-262
Project: JBoss AOP
Issue Type: Bug
Affects Versions: 1.5.0.GA
Environment: winxp
Reporter: Kamil Dworakowski
Assigned To: Kabir Khan
On start:
SEVERE Thread[ULC Communication Controller
Thread,6,main] com.ulcjava.base.server.ULCSession processRequests got exception while
processing [java.lang.NullPointerException
at
com.siemens.smarthome.component.tree.details.ThermostatView._getInstanceAdvisor(ThermostatView.java)
at
com.siemens.smarthome.component.tree.details.ThermostatView.detailsWidgets(ThermostatView.java)
at
com.siemens.smarthome.component.tree.details.AbstractView.<init>(AbstractView.java:43)
at
com.siemens.smarthome.component.tree.details.AbstractView.<init>(AbstractView.java:18)
at
com.siemens.smarthome.component.tree.details.ThermostatView.<init>(ThermostatView.java:14)
at
com.siemens.smarthome.component.tree.details.ThermostatView.ThermostatView_new_$aop(ThermostatView.java)
at com.siemens.smarthome.MainApplication.start(MainApplication.java:13)
at com.ulcjava.base.server.ULCSession.handleStartApplication(ULCSession.java:32)
at com.ulcjava.base.server.ULCSession.handleRequest(ULCSession.java:106)
at com.ulcjava.base.server.ULCSession.a(ULCSession.java:11)
at com.ulcjava.base.server.ULCSession.processRequests(ULCSession.java:134)
at
com.ulcjava.base.development.DevelopmentContainerAdapter.processRequests(DevelopmentContainerAdapter.java:2)
at
com.ulcjava.base.development.DevelopmentConnector.sendRequests(DevelopmentConnector.java:0)
at com.ulcjava.base.client.UISession$k_.run(UISession$k_.java:28)
at java.lang.Thread.run(Unknown Source)
]
<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
<aop>
<aspect name="ViewApplyButtonEnabler"
class="com.siemens.smarthome.aspects.gui.ViewApplyButtonEnablerAspect"
scope="PER_INSTANCE"/>
<bind pointcut="call(public *
*.PropertyTableWidget->addTextProperty(..))">
<advice name="addEnabler"
aspect="ViewApplyButtonEnabler"/>
</bind>
<prepare
expr="all(com.siemens.smarthome.component.tree.details.ThermostatView)"/>
</aop>
package com.siemens.smarthome.aspects.gui;
import java.util.HashMap;
import java.util.Map;
import org.jboss.aop.joinpoint.ConstructorCalledByConstructorInvocation;
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.MethodCalledByMethodInvocation;
import com.siemens.smarthome.component.tree.details.AbstractView;
import com.ulcjava.base.application.ULCButton;
import com.ulcjava.base.application.ULCTextField;
import com.ulcjava.base.application.enabler.*;
public class ViewApplyButtonEnablerAspect {
ULCHasChangedEnabler orEnabler = new ULCHasChangedEnabler();
public Object addEnabler(Invocation inv) throws Throwable {
ULCTextField enabler = (ULCTextField) inv.invokeNext();
orEnabler.add(enabler);
return enabler;
}
public Object setEnablerForButton(Invocation inv) throws Throwable {
ULCButton button = (ULCButton) inv.invokeNext();
if (button.getText().equals("Apply")) {
button.setEnabler(orEnabler);
}
return button;
}
}
package com.siemens.smarthome.component.tree.details;
import com.siemens.smarthome.util.PropertyTableWidget;
import com.ulcjava.base.application.*;
import com.ulcjava.base.application.enabler.ULCOrEnabler;
import com.ulcjava.base.application.event.ActionEvent;
import com.ulcjava.base.application.event.serializable.IActionListener;
import com.ulcjava.base.application.util.Font;
import com.ulcjava.base.application.util.Insets;
public abstract class AbstractView extends ULCGridBagLayoutPane {
protected ULCTextField nameTextField;
protected ULCButton applyButton;
private Boolean showName;
public AbstractView(String name, Boolean showName) {
this(name,showName,true);
}
@SuppressWarnings("serial")
public AbstractView(String name, Boolean showName, Boolean showApplyButton) {
super();
this.showName = showName;
GridBagConstraints constraints = new GridBagConstraints();
constraints.setGridX(0);
constraints.setInsets(new Insets(0,0,5,0));
constraints.setGridY(0);
ULCLabel kindLabel = new ULCLabel(name);
kindLabel.setFont(new Font(null,Font.BOLD,18));
this.add(kindLabel, constraints);
increaseGridy(constraints);
this.add(new ULCFiller(10,20),constraints);
increaseGridy(constraints);
constraints.setWeightX(1.0);
constraints.setFill(GridBagConstraints.BOTH);
this.add(detailsWidgets(),constraints);
}
private void increaseGridy(GridBagConstraints constraints) {
constraints.setGridY(constraints.getGridY()+1);
}
protected abstract void applyButtonPressed();
protected PropertyTableWidget detailsWidgets() {
PropertyTableWidget propertiesTable = new PropertyTableWidget();
addNameProperty(propertiesTable);
return propertiesTable;
}
protected void addNameProperty(PropertyTableWidget settingsProperties) {
if (showName)
nameTextField = settingsProperties.addTextProperty("Name");
else
nameTextField = new ULCTextField();
}
}
package com.siemens.smarthome.component.tree.details;
import com.siemens.aosd.smarthome.domain.Thermostat;
import com.siemens.smarthome.util.PropertyTableWidget;
import com.ulcjava.base.application.*;
@SuppressWarnings("serial")
public class ThermostatView extends AbstractView {
private ULCTextField temperatureTextBox;
public ThermostatView(Boolean showName) {
super("Thermostat", showName);
}
protected PropertyTableWidget detailsWidgets() {
PropertyTableWidget settingsProperties = super.detailsWidgets();
temperatureTextBox =
settingsProperties.addTextProperty(40, "Temperature", null);
return settingsProperties;
}
public void update(Object arg) {
}
private void enableControls() {
}
private void enable(ULCComponent comp) {
}
@Override
protected void applyButtonPressed() {
}
}
package com.siemens.smarthome.util;
import com.ulcjava.base.application.*;
import com.ulcjava.base.application.datatype.IDataType;
import com.ulcjava.base.application.datatype.ULCNumberDataType;
import com.ulcjava.base.application.util.Dimension;
import com.ulcjava.base.application.util.Insets;
/**
* Two column table. In first column name of property and in
* second editable value.
*
*/
@SuppressWarnings("serial")
public class PropertyTableWidget extends ULCGridBagLayoutPane {
GridBagConstraints constraints;
public PropertyTableWidget() {
constraints = constraintsForDetails();
constraints.setWeightX(0.0);
ULCFiller widthEnforcer = new ULCFiller(140,1);
constraints.setGridX(1);
add(widthEnforcer,constraints);
increaseGridy(constraints);
constraints.setGridX(0);
}
protected GridBagConstraints constraintsForDetails() {
GridBagConstraints constr = new GridBagConstraints();
constr.setGridX(0);
constr.setGridY(0);
constr.setInsets(new Insets(2,2,2,2));
constr.setAnchor(GridBagConstraints.WEST);
return constr;
}
public ULCTextField addTextProperty(String name) {
return addTextProperty(-1,name, null);
}
public ULCTextField addTextProperty( GridBagConstraints c,String name, IDataType
dataTypeValidator) {
return addTextProperty( -1, name, dataTypeValidator);
}
public ULCTextField addTextProperty(int preferedWidth,String name, IDataType
dataTypeValidator) {
constraints.setGridX(0);
constraints.setWeightX(1.0);
add(new ULCLabel(name+":"), constraints);
constraints.setWeightX(0);
ULCTextField textField = new ULCTextField();
if (dataTypeValidator != null)
textField.setDataType(dataTypeValidator);
if (preferedWidth < 0) preferedWidth = 140;
textField.setPreferredSize(new Dimension(preferedWidth,20));
constraints.setGridX(1);
add(textField,constraints);
increaseGridy(constraints);
return textField;
}
private void increaseGridy(GridBagConstraints constraints) {
constraints.setGridY(constraints.getGridY()+1);
}
}
package com.siemens.smarthome;
import java.io.Serializable;
import com.siemens.smarthome.component.tree.details.ThermostatView;
import com.ulcjava.base.application.*;
public class MainApplication extends AbstractApplication implements
Serializable {
public final void start() {
ThermostatView view = new ThermostatView(true);
}
private ULCRootPane createRootPane() {
ULCFrame frame = new ULCFrame("asdf");
// frame.setIconImage(IconFactory.getIcon(Constants.BUY_ICON));
frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);
frame.setSize(640, 460);
frame.setLocation(100, 100);
return frame;
}
}
package com.siemens.smarthome;
import com.ulcjava.base.development.DevelopmentRunner;
public final class MainApplicationRunner {
private MainApplicationRunner() {
}
public static void main(final String[] args) throws Exception {
DevelopmentRunner.setApplicationClass(MainApplication.class);
DevelopmentRunner.run();
}
}
package com.siemens.aosd.smarthome.domain;
public class Thermostat {}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: