下面列出了java.beans.IndexedPropertyChangeEvent#getIndex ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void propertyChange(PropertyChangeEvent event) {
Object value = event.getNewValue();
if (value.equals(event.getOldValue())) {
throw new Error("new value is equal to old one");
}
if (!this.name.equals(event.getPropertyName())) {
throw new Error("unexpected property name");
} else if (this.name.equals(COLOR)) {
if (!value.equals(this.color)) {
throw new Error("unexpected object value");
}
} else if (this.name.equals(BOOLEAN)) {
if (!value.equals(Boolean.valueOf(this.flag))) {
throw new Error("unexpected boolean value");
}
} else if (this.name.equals(INTEGER)) {
if (!value.equals(Integer.valueOf(this.value))) {
throw new Error("unexpected integer value");
}
} else {
throw new Error("unexpected property name");
}
if (event instanceof IndexedPropertyChangeEvent) {
IndexedPropertyChangeEvent ipce = (IndexedPropertyChangeEvent) event;
if (this.index != ipce.getIndex()) {
throw new Error("unexpected property index");
}
} else {
throw new Error("unexpected event type");
}
System.out.println(this.name + " at " + this.index + " is " + value);
this.name = null;
this.index = -1;
}
public void propertyChange(PropertyChangeEvent event) {
Object value = event.getNewValue();
if (value.equals(event.getOldValue())) {
throw new Error("new value is equal to old one");
}
if (!this.name.equals(event.getPropertyName())) {
throw new Error("unexpected property name");
} else if (this.name.equals(COLOR)) {
if (!value.equals(this.color)) {
throw new Error("unexpected object value");
}
} else if (this.name.equals(BOOLEAN)) {
if (!value.equals(Boolean.valueOf(this.flag))) {
throw new Error("unexpected boolean value");
}
} else if (this.name.equals(INTEGER)) {
if (!value.equals(Integer.valueOf(this.value))) {
throw new Error("unexpected integer value");
}
} else {
throw new Error("unexpected property name");
}
if (event instanceof IndexedPropertyChangeEvent) {
IndexedPropertyChangeEvent ipce = (IndexedPropertyChangeEvent) event;
if (this.index != ipce.getIndex()) {
throw new Error("unexpected property index");
}
} else {
throw new Error("unexpected event type");
}
System.out.println(this.name + " at " + this.index + " is " + value);
this.name = null;
this.index = -1;
}
public void propertyChange(PropertyChangeEvent event) {
Object value = event.getNewValue();
if (value.equals(event.getOldValue())) {
throw new Error("new value is equal to old one");
}
if (!this.name.equals(event.getPropertyName())) {
throw new Error("unexpected property name");
} else if (this.name.equals(COLOR)) {
if (!value.equals(this.color)) {
throw new Error("unexpected object value");
}
} else if (this.name.equals(BOOLEAN)) {
if (!value.equals(Boolean.valueOf(this.flag))) {
throw new Error("unexpected boolean value");
}
} else if (this.name.equals(INTEGER)) {
if (!value.equals(Integer.valueOf(this.value))) {
throw new Error("unexpected integer value");
}
} else {
throw new Error("unexpected property name");
}
if (event instanceof IndexedPropertyChangeEvent) {
IndexedPropertyChangeEvent ipce = (IndexedPropertyChangeEvent) event;
if (this.index != ipce.getIndex()) {
throw new Error("unexpected property index");
}
} else {
throw new Error("unexpected event type");
}
System.out.println(this.name + " at " + this.index + " is " + value);
this.name = null;
this.index = -1;
}
public void propertyChange(PropertyChangeEvent event) {
Object value = event.getNewValue();
if (value.equals(event.getOldValue())) {
throw new Error("new value is equal to old one");
}
if (!this.name.equals(event.getPropertyName())) {
throw new Error("unexpected property name");
} else if (this.name.equals(COLOR)) {
if (!value.equals(this.color)) {
throw new Error("unexpected object value");
}
} else if (this.name.equals(BOOLEAN)) {
if (!value.equals(Boolean.valueOf(this.flag))) {
throw new Error("unexpected boolean value");
}
} else if (this.name.equals(INTEGER)) {
if (!value.equals(Integer.valueOf(this.value))) {
throw new Error("unexpected integer value");
}
} else {
throw new Error("unexpected property name");
}
if (event instanceof IndexedPropertyChangeEvent) {
IndexedPropertyChangeEvent ipce = (IndexedPropertyChangeEvent) event;
if (this.index != ipce.getIndex()) {
throw new Error("unexpected property index");
}
} else {
throw new Error("unexpected event type");
}
System.out.println(this.name + " at " + this.index + " is " + value);
this.name = null;
this.index = -1;
}
public void propertyChange(PropertyChangeEvent event) {
Object value = event.getNewValue();
if (value.equals(event.getOldValue())) {
throw new Error("new value is equal to old one");
}
if (!this.name.equals(event.getPropertyName())) {
throw new Error("unexpected property name");
} else if (this.name.equals(COLOR)) {
if (!value.equals(this.color)) {
throw new Error("unexpected object value");
}
} else if (this.name.equals(BOOLEAN)) {
if (!value.equals(Boolean.valueOf(this.flag))) {
throw new Error("unexpected boolean value");
}
} else if (this.name.equals(INTEGER)) {
if (!value.equals(Integer.valueOf(this.value))) {
throw new Error("unexpected integer value");
}
} else {
throw new Error("unexpected property name");
}
if (event instanceof IndexedPropertyChangeEvent) {
IndexedPropertyChangeEvent ipce = (IndexedPropertyChangeEvent) event;
if (this.index != ipce.getIndex()) {
throw new Error("unexpected property index");
}
} else {
throw new Error("unexpected event type");
}
System.out.println(this.name + " at " + this.index + " is " + value);
this.name = null;
this.index = -1;
}
public void propertyChange(PropertyChangeEvent event) {
Object value = event.getNewValue();
if (value.equals(event.getOldValue())) {
throw new Error("new value is equal to old one");
}
if (!this.name.equals(event.getPropertyName())) {
throw new Error("unexpected property name");
} else if (this.name.equals(COLOR)) {
if (!value.equals(this.color)) {
throw new Error("unexpected object value");
}
} else if (this.name.equals(BOOLEAN)) {
if (!value.equals(Boolean.valueOf(this.flag))) {
throw new Error("unexpected boolean value");
}
} else if (this.name.equals(INTEGER)) {
if (!value.equals(Integer.valueOf(this.value))) {
throw new Error("unexpected integer value");
}
} else {
throw new Error("unexpected property name");
}
if (event instanceof IndexedPropertyChangeEvent) {
IndexedPropertyChangeEvent ipce = (IndexedPropertyChangeEvent) event;
if (this.index != ipce.getIndex()) {
throw new Error("unexpected property index");
}
} else {
throw new Error("unexpected event type");
}
System.out.println(this.name + " at " + this.index + " is " + value);
this.name = null;
this.index = -1;
}
public void propertyChange(PropertyChangeEvent event) {
Object value = event.getNewValue();
if (value.equals(event.getOldValue())) {
throw new Error("new value is equal to old one");
}
if (!this.name.equals(event.getPropertyName())) {
throw new Error("unexpected property name");
} else if (this.name.equals(COLOR)) {
if (!value.equals(this.color)) {
throw new Error("unexpected object value");
}
} else if (this.name.equals(BOOLEAN)) {
if (!value.equals(Boolean.valueOf(this.flag))) {
throw new Error("unexpected boolean value");
}
} else if (this.name.equals(INTEGER)) {
if (!value.equals(Integer.valueOf(this.value))) {
throw new Error("unexpected integer value");
}
} else {
throw new Error("unexpected property name");
}
if (event instanceof IndexedPropertyChangeEvent) {
IndexedPropertyChangeEvent ipce = (IndexedPropertyChangeEvent) event;
if (this.index != ipce.getIndex()) {
throw new Error("unexpected property index");
}
} else {
throw new Error("unexpected event type");
}
System.out.println(this.name + " at " + this.index + " is " + value);
this.name = null;
this.index = -1;
}
public void propertyChange(PropertyChangeEvent event) {
Object value = event.getNewValue();
if (value.equals(event.getOldValue())) {
throw new Error("new value is equal to old one");
}
if (!this.name.equals(event.getPropertyName())) {
throw new Error("unexpected property name");
} else if (this.name.equals(COLOR)) {
if (!value.equals(this.color)) {
throw new Error("unexpected object value");
}
} else if (this.name.equals(BOOLEAN)) {
if (!value.equals(Boolean.valueOf(this.flag))) {
throw new Error("unexpected boolean value");
}
} else if (this.name.equals(INTEGER)) {
if (!value.equals(Integer.valueOf(this.value))) {
throw new Error("unexpected integer value");
}
} else {
throw new Error("unexpected property name");
}
if (event instanceof IndexedPropertyChangeEvent) {
IndexedPropertyChangeEvent ipce = (IndexedPropertyChangeEvent) event;
if (this.index != ipce.getIndex()) {
throw new Error("unexpected property index");
}
} else {
throw new Error("unexpected event type");
}
System.out.println(this.name + " at " + this.index + " is " + value);
this.name = null;
this.index = -1;
}
public void propertyChange(PropertyChangeEvent event) {
Object value = event.getNewValue();
if (value.equals(event.getOldValue())) {
throw new Error("new value is equal to old one");
}
if (!this.name.equals(event.getPropertyName())) {
throw new Error("unexpected property name");
} else if (this.name.equals(COLOR)) {
if (!value.equals(this.color)) {
throw new Error("unexpected object value");
}
} else if (this.name.equals(BOOLEAN)) {
if (!value.equals(Boolean.valueOf(this.flag))) {
throw new Error("unexpected boolean value");
}
} else if (this.name.equals(INTEGER)) {
if (!value.equals(Integer.valueOf(this.value))) {
throw new Error("unexpected integer value");
}
} else {
throw new Error("unexpected property name");
}
if (event instanceof IndexedPropertyChangeEvent) {
IndexedPropertyChangeEvent ipce = (IndexedPropertyChangeEvent) event;
if (this.index != ipce.getIndex()) {
throw new Error("unexpected property index");
}
} else {
throw new Error("unexpected event type");
}
System.out.println(this.name + " at " + this.index + " is " + value);
this.name = null;
this.index = -1;
}
public void propertyChange(PropertyChangeEvent event) {
Object value = event.getNewValue();
if (value.equals(event.getOldValue())) {
throw new Error("new value is equal to old one");
}
if (!this.name.equals(event.getPropertyName())) {
throw new Error("unexpected property name");
} else if (this.name.equals(COLOR)) {
if (!value.equals(this.color)) {
throw new Error("unexpected object value");
}
} else if (this.name.equals(BOOLEAN)) {
if (!value.equals(Boolean.valueOf(this.flag))) {
throw new Error("unexpected boolean value");
}
} else if (this.name.equals(INTEGER)) {
if (!value.equals(Integer.valueOf(this.value))) {
throw new Error("unexpected integer value");
}
} else {
throw new Error("unexpected property name");
}
if (event instanceof IndexedPropertyChangeEvent) {
IndexedPropertyChangeEvent ipce = (IndexedPropertyChangeEvent) event;
if (this.index != ipce.getIndex()) {
throw new Error("unexpected property index");
}
} else {
throw new Error("unexpected event type");
}
System.out.println(this.name + " at " + this.index + " is " + value);
this.name = null;
this.index = -1;
}
public void propertyChange(PropertyChangeEvent event) {
Object value = event.getNewValue();
if (value.equals(event.getOldValue())) {
throw new Error("new value is equal to old one");
}
if (!this.name.equals(event.getPropertyName())) {
throw new Error("unexpected property name");
} else if (this.name.equals(COLOR)) {
if (!value.equals(this.color)) {
throw new Error("unexpected object value");
}
} else if (this.name.equals(BOOLEAN)) {
if (!value.equals(Boolean.valueOf(this.flag))) {
throw new Error("unexpected boolean value");
}
} else if (this.name.equals(INTEGER)) {
if (!value.equals(Integer.valueOf(this.value))) {
throw new Error("unexpected integer value");
}
} else {
throw new Error("unexpected property name");
}
if (event instanceof IndexedPropertyChangeEvent) {
IndexedPropertyChangeEvent ipce = (IndexedPropertyChangeEvent) event;
if (this.index != ipce.getIndex()) {
throw new Error("unexpected property index");
}
} else {
throw new Error("unexpected event type");
}
System.out.println(this.name + " at " + this.index + " is " + value);
this.name = null;
this.index = -1;
}
public void propertyChange(PropertyChangeEvent event) {
Object value = event.getNewValue();
if (value.equals(event.getOldValue())) {
throw new Error("new value is equal to old one");
}
if (!this.name.equals(event.getPropertyName())) {
throw new Error("unexpected property name");
} else if (this.name.equals(COLOR)) {
if (!value.equals(this.color)) {
throw new Error("unexpected object value");
}
} else if (this.name.equals(BOOLEAN)) {
if (!value.equals(Boolean.valueOf(this.flag))) {
throw new Error("unexpected boolean value");
}
} else if (this.name.equals(INTEGER)) {
if (!value.equals(Integer.valueOf(this.value))) {
throw new Error("unexpected integer value");
}
} else {
throw new Error("unexpected property name");
}
if (event instanceof IndexedPropertyChangeEvent) {
IndexedPropertyChangeEvent ipce = (IndexedPropertyChangeEvent) event;
if (this.index != ipce.getIndex()) {
throw new Error("unexpected property index");
}
} else {
throw new Error("unexpected event type");
}
System.out.println(this.name + " at " + this.index + " is " + value);
this.name = null;
this.index = -1;
}
public void propertyChange(PropertyChangeEvent event) {
Object value = event.getNewValue();
if (value.equals(event.getOldValue())) {
throw new Error("new value is equal to old one");
}
if (!this.name.equals(event.getPropertyName())) {
throw new Error("unexpected property name");
} else if (this.name.equals(COLOR)) {
if (!value.equals(this.color)) {
throw new Error("unexpected object value");
}
} else if (this.name.equals(BOOLEAN)) {
if (!value.equals(Boolean.valueOf(this.flag))) {
throw new Error("unexpected boolean value");
}
} else if (this.name.equals(INTEGER)) {
if (!value.equals(Integer.valueOf(this.value))) {
throw new Error("unexpected integer value");
}
} else {
throw new Error("unexpected property name");
}
if (event instanceof IndexedPropertyChangeEvent) {
IndexedPropertyChangeEvent ipce = (IndexedPropertyChangeEvent) event;
if (this.index != ipce.getIndex()) {
throw new Error("unexpected property index");
}
} else {
throw new Error("unexpected event type");
}
System.out.println(this.name + " at " + this.index + " is " + value);
this.name = null;
this.index = -1;
}
/**
* This method gets called when a bound property is changed.
*
* @param evt A PropertyChangeEvent object describing the event source and the property that has changed.
*/
public void propertyChange( final PropertyChangeEvent evt ) {
if ( ReportDesignerContext.REPORT_RENDER_CONTEXT_PROPERTY.equals( evt.getPropertyName() ) == false ) {
return;
}
if ( !( evt instanceof IndexedPropertyChangeEvent ) ) {
throw new UnsupportedOperationException();
}
final JTabbedPane editorPanes = getReportEditorPane();
final IndexedPropertyChangeEvent ievt = (IndexedPropertyChangeEvent) evt;
if ( ievt.getNewValue() != null ) {
// added
final ReportRenderContext renderContext = (ReportRenderContext) ievt.getNewValue();
DefaultReportDesignerContext reportDesignerContext = getContext();
final ReportRendererComponent rendererComponent =
new ReportRendererComponent( reportDesignerContext, renderContext );
final String title = renderContext.getTabName();
final Icon icon = renderContext.getIcon();
final TabRenderer tabRenderer = new TabRenderer( icon, title, reportDesignerContext, editorPanes );
editorPanes.addTab( title, null, rendererComponent );
editorPanes.setTabComponentAt( editorPanes.getTabCount() - 1, tabRenderer );
editorPanes.setSelectedComponent( rendererComponent );
renderContext.addPropertyChangeListener( "tabName",
new DocumentNameChangeHandler( renderContext, tabRenderer, editorPanes.getTabCount() - 1 ) );
} else if ( ievt.getOldValue() != null ) {
if ( editorPanes.getTabCount() <= 0 ) {
return;
}
// removed
int index = ievt.getIndex();
final ReportRenderContext reportRenderContext = (ReportRenderContext) ievt.getOldValue();
boolean removedTab = false;
for ( int i = 0; i < editorPanes.getTabCount(); i++ ) {
final Component tabContent = editorPanes.getComponentAt( i );
if ( tabContent instanceof ReportRendererComponent ) {
final ReportRendererComponent myReportRenderer = (ReportRendererComponent) tabContent;
if ( myReportRenderer.getRenderContext() == reportRenderContext ) {
index = i;
editorPanes.removeTabAt( index );
removedTab = true;
myReportRenderer.dispose();
break;
}
}
}
// if we didn't remove a tab, the tab was probably not a report, so remove it by index
if ( !removedTab ) {
editorPanes.removeTabAt( index );
}
// unregister the listeners ...
if ( editorPanes.getTabCount() > 0 ) {
if ( index < editorPanes.getTabCount() ) {
editorPanes.setSelectedIndex( index );
} else {
editorPanes.setSelectedIndex( editorPanes.getTabCount() - 1 );
}
}
}
recomputeAllTabTitles();
rebuildReportMenu();
}