Java Code Examples for java.util.Observer#update()

The following examples show how to use java.util.Observer#update() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DBMap.java    From Qora with MIT License 6 votes vote down vote up
@Override
public void addObserver(Observer o) 
{
	//ADD OBSERVER
	super.addObserver(o);	
	
	//NOTIFY LIST
	if(this.getObservableData().containsKey(NOTIFY_LIST))
	{
		//CREATE LIST
		SortableList<T, U> list = new SortableList<T, U>(this);
		
		//UPDATE
		o.update(null, new ObserverMessage(this.getObservableData().get(NOTIFY_LIST), list));
	}
}
 
Example 2
Source File: DetectingMisusedMatchersTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void should_report_argument_locations_when_argument_matchers_misused() {
    try {
    	Observer observer = mock(Observer.class);
    	
    	misplaced_anyInt_argument_matcher();
    	misplaced_anyObject_argument_matcher();
    	misplaced_anyBoolean_argument_matcher();
    	
    	observer.update(null, null);
    	
    	validateMockitoUsage();
    	fail();
    } catch (InvalidUseOfMatchersException e) {
        assertContains("DetectingMisusedMatchersTest.misplaced_anyInt_argument_matcher", e.getMessage());
        assertContains("DetectingMisusedMatchersTest.misplaced_anyObject_argument_matcher", e.getMessage());
        assertContains("DetectingMisusedMatchersTest.misplaced_anyBoolean_argument_matcher", e.getMessage());
    }
}
 
Example 3
Source File: TravelStrutsObservable.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("null")
@Override
public void notifyObservers(final Object arg) {
    TravelMvcWrapperBean wrapper = null;
    if (arg instanceof TravelMvcWrapperBean) {
        wrapper = (TravelMvcWrapperBean) arg;
    }
    else if (arg instanceof Object[]) {
        final Object[] args = (Object[]) arg;
        if (args != null && args.length > 0
            && args[0] instanceof TravelMvcWrapperBean) {
            wrapper = (TravelMvcWrapperBean) args[0];
        }
    }

    final String eventName = wrapper.getMethodToCall();
    for (final Observer observer : getObservers().get(eventName)) {
        observer.update(this, arg);
    }
    clearChanged();
}
 
Example 4
Source File: ParetoPanel.java    From charts with Apache License 2.0 5 votes vote down vote up
private void modelChanged(){
    if(null != observerList && !observerList.isEmpty()){
        for(Observer observer: observerList){
            observer.update(null, null);
        }
    }
}
 
Example 5
Source File: AwaitingPhase.java    From stendhal with GNU General Public License v2.0 5 votes vote down vote up
/**
 * prepare NPC to walk through his multizone pathes and do some actions during that.
 */
private void leadNPC() {
	final StendhalRPZone zone = fullpathin.get(0).get().first();
	final int x=fullpathin.get(0).get().second().get(0).getX();
	final int y=fullpathin.get(0).get().second().get(0).getY();
	piedpiper.setPosition(x, y);
	zone.add(piedpiper);
	Observer o = new MultiZonesFixedPath(piedpiper, fullpathin,
					new NPCFollowing(mainNPC, piedpiper,
						new NPCChatting(piedpiper, mainNPC, conversations, explainations,
							new GoToPosition(piedpiper, PathsBuildHelper.getAdosTownHallMiddlePoint(),
								new MultiZonesFixedPath(piedpiper, fullpathout,
									new PhaseSwitcher(this))))));
	o.update(null, null);
}
 
Example 6
Source File: OutgoingPhase.java    From stendhal with GNU General Public License v2.0 5 votes vote down vote up
/**
 * prepare NPC to walk through his multizone path.
 */
private void leadNPC() {
	final StendhalRPZone zone = fullpath.get(0).get(0).get().first();
	final int x=fullpath.get(0).get(0).getPath().get(0).getX();
	final int y=fullpath.get(0).get(0).getPath().get(0).getY();
	piedpiper.setPosition(x, y);
	zone.add(piedpiper);
	Observer o = new MultiZonesFixedPathsList(
					piedpiper,
					fullpath,
					new AttractRat(),
					new RoadsEnd(
							new PhaseSwitcher(this)));
	o.update(null, null);
}
 
Example 7
Source File: Network.java    From Qora with MIT License 5 votes vote down vote up
@Override
public void addObserver(Observer o)
{
	super.addObserver(o);
	
	//SEND CONNECTEDPEERS ON REGISTER
	o.update(this, new ObserverMessage(ObserverMessage.LIST_PEER_TYPE, this.connectedPeers));
}
 
Example 8
Source File: Controller.java    From Qora with MIT License 5 votes vote down vote up
@Override
public void addObserver(Observer o) 
{
	//ADD OBSERVER TO SYNCHRONIZER
	//this.synchronizer.addObserver(o);
	DBSet.getInstance().getBlockMap().addObserver(o);
	
	//ADD OBSERVER TO BLOCKGENERATOR
	//this.blockGenerator.addObserver(o);
	DBSet.getInstance().getTransactionMap().addObserver(o);
		
	//ADD OBSERVER TO NAMESALES
	DBSet.getInstance().getNameExchangeMap().addObserver(o);
	
	//ADD OBSERVER TO POLLS
	DBSet.getInstance().getPollMap().addObserver(o);
	
	//ADD OBSERVER TO ASSETS
	DBSet.getInstance().getAssetMap().addObserver(o);
	
	//ADD OBSERVER TO ORDERS
	DBSet.getInstance().getOrderMap().addObserver(o);
			
	//ADD OBSERVER TO TRADES
	DBSet.getInstance().getTradeMap().addObserver(o);
	
	//ADD OBSERVER TO BALANCES
	DBSet.getInstance().getBalanceMap().addObserver(o);
	
	//ADD OBSERVER TO CONTROLLER
	super.addObserver(o);
	o.update(this, new ObserverMessage(ObserverMessage.NETWORK_STATUS, this.status));
}
 
Example 9
Source File: FrontendConnection.java    From heisenberg with Apache License 2.0 5 votes vote down vote up
public void writeCode(boolean isSuc, int code) {
    if (obList.size() == 0)
        return;
    String[] data = new String[] { new String("" + isSuc), code + "" };
    for (Observer o : obList) {
        // 通知
        o.update(null, data);
    }
}
 
Example 10
Source File: App.java    From ForPDA with GNU General Public License v3.0 4 votes vote down vote up
public void addStatusBarSizeObserver(Observer observer) {
    statusBarSizeObservables.addObserver(observer);
    observer.update(statusBarSizeObservables, null);
}
 
Example 11
Source File: Wallet.java    From Qora with MIT License 4 votes vote down vote up
@Override
public void addObserver(Observer o)
{
	super.addObserver(o);
	
	//REGISTER ON ACCOUNTS
	this.database.getAccountMap().addObserver(o);
	
	//REGISTER ON TRANSACTIONS
	this.database.getTransactionMap().addObserver(o);
	
	//REGISTER ON BLOCKS
	this.database.getBlockMap().addObserver(o);
	
	//REGISTER ON NAMES
	this.database.getNameMap().addObserver(o);
	
	//REGISTER ON NAME SALES
	this.database.getNameSaleMap().addObserver(o);
	
	//REGISTER ON POLLS
	this.database.getPollMap().addObserver(o);
	
	//REGISTER ON ASSETS
	this.database.getAssetMap().addObserver(o);

	//REGISTER ON ORDERS
	this.database.getOrderMap().addObserver(o);
	
	//REGISTER ON ASSET FAVORITES
	this.database.getAssetFavoritesSet().addObserver(o);
	
	//SEND STATUS
	int status = STATUS_LOCKED;
	if(this.isUnlocked())
	{
		status = STATUS_UNLOCKED;
	}
	
	o.update(this, new ObserverMessage(ObserverMessage.WALLET_STATUS, status));
}