java.util.Observable Java Examples

The following examples show how to use java.util.Observable. 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: TransactionsTableModel.java    From Qora with MIT License 6 votes vote down vote up
@SuppressWarnings("unchecked")	
public synchronized void syncUpdate(Observable o, Object arg)
{
	ObserverMessage message = (ObserverMessage) arg;
	
	//CHECK IF NEW LIST
	if(message.getType() == ObserverMessage.LIST_TRANSACTION_TYPE)
	{
		if(this.transactions == null)
		{
			this.transactions = (SortableList<byte[], Transaction>) message.getValue();
			this.transactions.registerObserver();
			this.transactions.sort(TransactionMap.TIMESTAMP_INDEX, true);
		}
		
		this.fireTableDataChanged();
	}
	
	//CHECK IF LIST UPDATED
	if(message.getType() == ObserverMessage.ADD_TRANSACTION_TYPE || message.getType() == ObserverMessage.REMOVE_TRANSACTION_TYPE)
	{
		this.fireTableDataChanged();
	}	
}
 
Example #2
Source File: DistributeAccountingLinesEvent.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void update(Observable arg0, Object arg1) {

    final TravelMvcWrapperBean wrapper = (TravelMvcWrapperBean) arg1;
    boolean rulePassed = true;
    wrapper.setDistribution(getAccountingDistributionService().buildDistributionFrom(wrapper.getTravelDocument()));
    // check any business rules
    rulePassed &= getRuleService().applyRules(new AssignDistributionAccountingLinesEvent(TemPropertyConstants.NEW_IMPORTED_EXPENSE_LINE, wrapper.getTravelDocument(), wrapper));

    if (rulePassed){
        List<TemSourceAccountingLine> newLines = getAccountingDistributionService().distributionToSouceAccountingLines(wrapper.getAccountDistributionsourceAccountingLines(),
                wrapper.getDistribution(), wrapper.getTravelDocument().getSourceTotal(), wrapper.getTravelDocument().getExpenseLimit());

        for (TemSourceAccountingLine newLine : newLines) {
            wrapper.getTravelDocument().addSourceAccountingLine(newLine);
        }
        wrapper.setAccountDistributionsourceAccountingLines(new ArrayList<TemDistributionAccountingLine>());
        wrapper.setAccountDistributionnextSourceLineNumber(new Integer(1));
    }

}
 
Example #3
Source File: Sixi2Sim.java    From Robot-Overlord-App with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void update(Observable obs, Object obj) {
	if(obs == endEffector) {
		if(!lock.isLocked()) {
			lock.lock();
			//setPoseIK(endEffector.getPoseWorld());
			endEffectorTarget.setPoseWorld(endEffector.getPoseWorld());
			lock.unlock();
		}
	}
	if(obs==endEffectorTarget) {
		if(!lock.isLocked()) {
			lock.lock();
			setPoseIK(endEffectorTarget.getPoseWorld());
			lock.unlock();
		}
	}
	super.update(obs, obj);
}
 
Example #4
Source File: EventDispatch.java    From AndroidStudyDemo with GNU General Public License v2.0 6 votes vote down vote up
public void update(Observable o, Object arg) {
    // 事件的源头
    Product product = (Product) arg;
    // 事件
    ProductEvent event = (ProductEvent) o;

    // 处理者处理,这里是中介者模式的核心,可以是很复杂的业务逻辑
    for (EventCustomer e : customer) {
        // 处理能力是否匹配
        for (EventCustomType t : e.getCustomType()) {
            if (t.getValue() == event.getEventType().getValue()) {
                e.exec(event);
            }
        }

    }
}
 
Example #5
Source File: RemoveDistributionAccountingLineEvent.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void update(Observable arg0, Object arg1) {
    if (!(arg1 instanceof Object[])) {
        return;
    }
    final Object[] args = (Object[]) arg1;

    if (!(args[WRAPPER_ARG_IDX] instanceof TravelMvcWrapperBean)) {
        return;
    }
    TravelMvcWrapperBean wrapper = (TravelMvcWrapperBean) args[WRAPPER_ARG_IDX];
    
    final TravelDocument document = wrapper.getTravelDocument();
    final Integer deleteIndex = (Integer) args[SELECTED_LINE_ARG_IDX];
    
    wrapper.getAccountDistributionsourceAccountingLines().remove(deleteIndex.intValue());
    int lineNumber = wrapper.getAccountDistributionnextSourceLineNumber() - 1;
    wrapper.setAccountDistributionnextSourceLineNumber(lineNumber);
    int counter = 1;
    for (AccountingLine line : wrapper.getAccountDistributionsourceAccountingLines()){
        line.setSequenceNumber(new Integer(counter));
        counter++;
    }
    
    getAccountingDistributionService().buildDistributionFrom(document);
}
 
Example #6
Source File: SyncOnCommit.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public void update(Observable obj, Object arg) {

		if (SanityManager.DEBUG) {
			if (arg == null)
				SanityManager.THROWASSERT("still on observr list " + this);
		}

		if (arg.equals(RawTransaction.COMMIT)) {
			openContainerAndDoIt((RawTransaction) obj);
		}

		// remove this object if we are commiting, aborting or the container is being dropped
		if (arg.equals(RawTransaction.COMMIT) || arg.equals(RawTransaction.ABORT)
			|| arg.equals(identity)) {
			obj.deleteObserver(this);
		}
	}
 
Example #7
Source File: MainProjectWizardPage.java    From sarl with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("synthetic-access")
@Override
public void update(Observable observable, Object arg) {
	try {
		final IWorkspace workspace = JavaPlugin.getWorkspace();
		final String name = MainProjectWizardPage.this.nameGroup.getName();
		checkProjectName(workspace, name);
		final IProject handle = checkProjectExist(workspace, name);
		final String location = MainProjectWizardPage.this.locationGroup.getLocation().toOSString();
		final IPath projectPath = checkLocationSyntax(location);
		validateLocation(workspace, handle, projectPath);

		setErrorMessage(null);
		setMessage(null);
		setPageComplete(true);

	} catch (ValidationException e) {
		setMessage(e.getMessage());
		setErrorMessage(e.getErrorMessage());
		setPageComplete(false);
	}
}
 
Example #8
Source File: AnalyzeAndForwardToolPanel.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
public void update(Observable observable, Object obj) {
     if (observable instanceof OpenSimDB){
        if (obj instanceof ModelEvent) {
             if (OpenSimDB.getInstance().hasModel(toolModel.getOriginalModel()))
                 return;
             else {
                 toolModel.deleteObserver(this);
                 OpenSimDB.getInstance().deleteObserver(this);
                 NotifyDescriptor.Message dlg =
                       new NotifyDescriptor.Message("Model used by the tool is being closed. Closing tool.");
                 DialogDisplayer.getDefault().notify(dlg);
                 this.close();
                 return;
             }        
        }
        return;
    }
   if(observable == toolModel && obj == AbstractToolModel.Operation.ExecutionStateChanged)

   //if(observable == toolModel && (obj == AbstractToolModel.Operation.ExecutionStateChanged ||
   //        obj == AbstractToolModel.Operation.InputDataChanged))
      updateDialogButtons();
   else
      updateFromModel(); 
}
 
Example #9
Source File: SynthesizerBase.java    From AssistantBySDK with Apache License 2.0 6 votes vote down vote up
/**
 * 合成语音,等待合成的队列将被清空,合成中的语音将被打断,打断后马上开始合成
 *
 * @param msg
 * @return
 */
public io.reactivex.Observable<SpeechMsg> startSpeakAbsolute(SpeechMsg msg) {
    Log.i(TAG, "startSpeakAbsolute>>>>>>>>" + msg.text());
    sLock.lock();
    int r = 0;
    try {
        if (isSpeaking()) {
            Log.e(TAG, "startSpeakAbsolute isSpeaking........");
            if (mediator.compareSpeechMsg(msg, currentMessage)) {       //比较合成文本优先级(导航最优)
                stopSpeakingAbsolte(msg);    //准备合成的文本为导航相关,停止当前合成,优先播放
            } else {
                Log.e(TAG, "startSpeakAbsolute>>addMessageWaitSpeak");
                messages.offer(msg); //准备合成的文本为普通文本,放入合成队列中等待,当前合成完成后在合成
                return io.reactivex.Observable.empty();
            }
        }
        return startSpeak(msg);
    } finally {
        sLock.unlock();
    }
}
 
Example #10
Source File: BitsoWebSocketObserver.java    From bitso-java with MIT License 6 votes vote down vote up
public void update(Observable o, Object arg) {
    // Update message
    if(arg instanceof String){
        String messageReceived = ((String) arg);
        System.out.println(messageReceived);
        mMessagesReceived.add(messageReceived);
    }
    
    // On connect/disconnect
    if(arg instanceof Boolean){
        mWSConnected = ((Boolean) arg);
        if(mWSConnected){
            System.out.println("Web socket is now connected");
        }else{
            System.out.println("Web socket is now disconnected");
        }
        
    }
}
 
Example #11
Source File: TalkingHead.java    From JVoiceXML with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Handles incoming BML Packages & executes BML-Script.
 */
@Override
public final void update(final Observable arg0, final Object arg1) {
    if (arg0 == talkingHeadInputConnection) {
        // Cast BML-Message
        // BML msg = (BML) arg1;
        BML msg = null;
        try {
            msg = talkingHeadBMLParser.generateBML((String) arg1);
        } catch (JDOMException | IOException e) {
            e.printStackTrace();
        }

        if (msg == null) {
            return;
        }

        // Reset
        talkingHeadAnimator.setCurrentAnimationID("[CURRENT_ID]");

        // Start Execution
        talkingHeadBMLExecutor.start(msg);
    }
}
 
Example #12
Source File: DexDex.java    From pokemon-go-xposed-mitm with GNU General Public License v3.0 6 votes vote down vote up
public static void showUiBlocker(Activity startActivity, CharSequence title, CharSequence msg) {
    if(debug) {
        Log.d(TAG, "showUiBlocker() for " + startActivity);
    }
    uiBlockedActivity = startActivity;
    final ProgressDialog progressDialog = new ProgressDialog(startActivity);
    progressDialog.setMessage(msg);
    progressDialog.setTitle(title);
    progressDialog.setIndeterminate(true);
    dexOptProgressObserver = new Observer() {
        @Override
        public void update(Observable observable, Object o) {
            if(o==Integer.valueOf(PROGRESS_COMPLETE)) {
                progressDialog.dismiss();
            }
        }
    };
    
    progressDialog.show();
}
 
Example #13
Source File: WalletNameSalesTableModel.java    From Qora with MIT License 6 votes vote down vote up
@SuppressWarnings("unchecked")
public synchronized void syncUpdate(Observable o, Object arg)
{
	ObserverMessage message = (ObserverMessage) arg;
	
	//CHECK IF NEW LIST
	if(message.getType() == ObserverMessage.LIST_NAME_SALE_TYPE)
	{
		if(this.nameSales == null)
		{
			this.nameSales = (SortableList<Tuple2<String, String>, BigDecimal>) message.getValue();
			this.nameSales.registerObserver();
			this.nameSales.sort(NameSaleMap.NAME_INDEX);
		}
		
		this.fireTableDataChanged();
	}
	
	//CHECK IF LIST UPDATED
	if(message.getType() == ObserverMessage.ADD_NAME_SALE_TYPE || message.getType() == ObserverMessage.REMOVE_NAME_SALE_TYPE)
	{
		this.fireTableDataChanged();
	}	
}
 
Example #14
Source File: MappingPanelContainer.java    From datasync with MIT License 6 votes vote down vote up
@Override
public void update(Observable o, Object arg) {
    ControlFileModel model = (ControlFileModel) o;
    //Check to the if the structure has changed.  If it has, then we need to layout it out again.
    if (model.getCsvModel().getColumnCount() != lastColumnsCount)
        initializeComponents();
    else {
        //If not, then update each of the components
        for (Object obj : this.getComponents()) {
            if (obj.getClass().equals(MappingPanel.class)) {
                MappingPanel panel = (MappingPanel) obj;
                panel.update();
            }
        }
    }
}
 
Example #15
Source File: ValidationPanel.java    From audiveris with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * A degenerated version, just to disable by default the
 * verification actions whenever a new task activity is notified.
 * These actions are then re-enabled only at the end of the validation run.
 *
 * @param obs    not used
 * @param unused not used
 */
@Override
public void update (Observable obs,
                    Object unused)
{
    weakPositiveAction.setEnabled(!weakPositives.isEmpty());
    falsePositiveAction.setEnabled(!falsePositives.isEmpty());
    weakNegativeAction.setEnabled(!weakNegatives.isEmpty());

    Task task = (Task) obs;
    validateAction.setEnabled(task.getActivity() == Task.Activity.INACTIVE);
}
 
Example #16
Source File: BalancesTableModel.java    From Qora with MIT License 5 votes vote down vote up
@Override
public void update(Observable o, Object arg) 
{
	try
	{
		this.syncUpdate(o, arg);
	}
	catch(Exception e)
	{
		//GUI ERROR
	}
}
 
Example #17
Source File: CleanUpTabPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected void registerPreference(final CheckboxPreference preference) {
	fCount++;
	preference.addObserver(new Observer() {
		public void update(Observable o, Object arg) {
			if (preference.getChecked()) {
				setSelectedCleanUpCount(fSelectedCount + 1);
			} else {
				setSelectedCleanUpCount(fSelectedCount - 1);
			}
		}
	});
	if (preference.getChecked()) {
		setSelectedCleanUpCount(fSelectedCount + 1);
	}
}
 
Example #18
Source File: EventReceiverCoordinator.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void init() {
    // register a single observer for the EB system (switched from local observer)
    eventTrackingService.addObserver(new Observer() {
        public void update(Observable o, Object arg) {
            if (arg instanceof Event) {
                Event event = (Event) arg;
                handleEvent(event);
            }
        }
    });
}
 
Example #19
Source File: PeersTableModel.java    From Qora with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")	
public synchronized void syncUpdate(Observable o, Object arg)
{
	ObserverMessage message = (ObserverMessage) arg;
	
	if(message.getType() == ObserverMessage.LIST_PEER_TYPE)
	{
		this.peers = (List<Peer>) message.getValue();
	
		this.fireTableDataChanged();
	}
}
 
Example #20
Source File: AnalysisSetPanel.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
public void update(Observable observable, Object obj) {
   AbstractToolModel.Operation op = (AbstractToolModel.Operation)obj;
   switch(op) {
      case AllDataChanged: 
      case AnalysisAddedOrRemoved:
         fireTableDataChanged();
         break;
      case AnalysisDataChanged:
         fireTableRowsUpdated(0,getRowCount());
         break;
   }
}
 
Example #21
Source File: DataItemObservableValue.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
private Observer createObserver ()
{
    return new Observer () {

        @Override
        public void update ( final Observable o, final Object arg )
        {
            if ( arg instanceof DataItemValue )
            {
                handleUpdate ( this, (DataItemValue)arg );
            }
        }
    };
}
 
Example #22
Source File: HoraireFragment.java    From ETSMobile-Android2 with Apache License 2.0 5 votes vote down vote up
@Override
    public void update(Observable observable, Object data) {

//        customProgressDialog.dismiss();
        progressBarSyncHoraire.setVisibility(ProgressBar.GONE);

        fillSeancesList(dateTime.toDate());
    }
 
Example #23
Source File: ObservingCourier.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * This method is called whenever the observed object is changed. An application calls an <tt>Observable</tt> object's <code>notifyObservers</code> method to have all the object's observers notified of the change. default implementation is to
 * cause the courier service to deliver to the interface controlled by my controller. Extensions can override.
 * 
 * @param o
 *        the observable object.
 * @param arg
 *        an argument passed to the <code>notifyObservers</code> method.
 */
public void update(Observable o, Object arg)
{
	// ignore changes when not enabled
	if (!getEnabled())
	{
		return;
	}

	if (!check(arg)) return;

	m_courierService.deliver(new DirectRefreshDelivery(getDeliveryId(), getElementId()));
}
 
Example #24
Source File: WalletTransactionsTableModel.java    From Qora with MIT License 5 votes vote down vote up
@Override
public void update(Observable o, Object arg) 
{
	try
	{
		this.syncUpdate(o, arg);
	}
	catch(Exception e)
	{
		//GUI ERROR
	}
}
 
Example #25
Source File: WalletOrdersTableModel.java    From Qora with MIT License 5 votes vote down vote up
@Override
public void update(Observable o, Object arg) 
{	
	try
	{
		this.syncUpdate(o, arg);
	}
	catch(Exception e)
	{
		//GUI ERROR
	}
}
 
Example #26
Source File: EventListener.java    From attic-stratos with Apache License 2.0 5 votes vote down vote up
@Override
public void update(Observable o, Object arg) {
    if (arg instanceof Event) {
        Event event = (Event) arg;
        if (log.isDebugEnabled()) {
            log.debug(String.format("Event received: %s", event.getClass().getName()));
        }
        onEvent(event);
    }
}
 
Example #27
Source File: ChaseTask.java    From Llunatic with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void update(Observable o, Object arg) {
    if (chaseState.isValid()) {
        return;
    }
    fireChaseKilled();
}
 
Example #28
Source File: ContactDetails.java    From desktopclient-java with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void updateOnEDT(Observable o, Object arg) {
    // may have changed: avatar...
    mAvatarImage.update();
    // ...contact name...
    mNameField.setText(mContact.getName());
    mNameField.setInputPrompt(mContact.getName());
    Contact.Subscription subscription = mContact.getSubScription();
    String auth = Tr.tr("Unknown");
    switch(subscription) {
        case PENDING: auth = Tr.tr("Awaiting reply"); break;
        case SUBSCRIBED: auth = Tr.tr("Authorized"); break;
        case UNSUBSCRIBED: auth = Tr.tr("Not authorized"); break;
    }
    // ...subscription...
    mSubscrButton.setVisible(subscription != Contact.Subscription.SUBSCRIBED);
    mSubscrButton.setEnabled(subscription == Contact.Subscription.UNSUBSCRIBED);
    mSubscrStatus.setText(auth);
    // ...and/or key
    String hasKey = "<html>";
    if (mContact.hasKey()) {
        hasKey += Tr.tr("Available")+"</html>";
        TooltipManager.removeTooltips(mKeyStatus);
        mFPArea.setText(Utils.fingerprint(mContact.getFingerprint()));
        mFPLabel.setVisible(true);
        mFPArea.setVisible(true);
    } else {
        hasKey += "<font color='red'>"+Tr.tr("Not Available")+"</font></html>";
        String keyText = Tr.tr("The public key for this contact could not yet be received");
        TooltipManager.addTooltip(mKeyStatus, keyText);
        mFPLabel.setVisible(false);
        mFPArea.setVisible(false);
    }
    mKeyStatus.setText(hasKey);
    mUpdateButton.setEnabled(mContact.isKontalkUser() &&
            subscription == Contact.Subscription.SUBSCRIBED);
}
 
Example #29
Source File: TradesTableModel.java    From Qora with MIT License 5 votes vote down vote up
@Override
public void update(Observable o, Object arg) 
{	
	try
	{
		this.syncUpdate(o, arg);
	}
	catch(Exception e)
	{
		//GUI ERROR
	}
}
 
Example #30
Source File: GeoJsonFeature.java    From android-maps-utils with Apache License 2.0 5 votes vote down vote up
/**
 * Update is called if the developer modifies a style that is stored in this feature
 *
 * @param observable GeoJsonStyle object
 * @param data       null, no extra argument is passed through the notifyObservers method
 */
@Override
public void update(Observable observable, Object data) {
    if (observable instanceof GeoJsonStyle) {
        checkRedrawFeature((GeoJsonStyle) observable);
    }
}