java.util.Observer Java Examples

The following examples show how to use java.util.Observer. 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: Sequence.java    From NanoJ-Fluidics with MIT License 6 votes vote down vote up
public Sequence(Observer changer) {
    super();

    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        ReportingUtils.logError(e);
    }

    this.stepObserver = changer;

    this.suckStep = new Step(0, "suck", false,false,10, Step.TimeUnit.SECS, Syringe.PERISTALTIC, 7, Step.VolumeUnit.UL, Pump.Action.Withdraw);
    this.suckStep.setIsSuckStep();

    add(new Step(1, "Start", true, false, 1, Step.TimeUnit.SECS, Syringe.BD50,  0.5, Step.VolumeUnit.ML,Pump.Action.Infuse));
    add(new Step(2, "Middle", true, false,1, Step.TimeUnit.SECS, Syringe.BD10, 1, Step.VolumeUnit.ML,Pump.Action.Infuse));
    add(new Step(3, "Finish", true,false,1, Step.TimeUnit.SECS, Syringe.BD1,100, Step.VolumeUnit.UL,Pump.Action.Infuse));

}
 
Example #2
Source File: NullClassLoader.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {

        System.err.println(
            "\nTest creating proxy class with the null class loader.\n");

        try {
            Class p = Proxy.getProxyClass(null,
                new Class[] { Runnable.class, Observer.class });
            System.err.println("proxy class: " + p);

            ClassLoader loader = p.getClassLoader();
            System.err.println("proxy class's class loader: " + loader);

            if (loader != null) {
                throw new RuntimeException(
                    "proxy class not defined in the null class loader");
            }

            System.err.println("\nTEST PASSED");

        } catch (Throwable e) {
            System.err.println("\nTEST FAILED:");
            e.printStackTrace();
            throw new RuntimeException("TEST FAILED: " + e.toString());
        }
    }
 
Example #3
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 #4
Source File: PCGenFrame.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
public PCGenFrame(UIContext uiContext)
{
	this.uiContext = Objects.requireNonNull(uiContext);
	Globals.setRootFrame(this);
	this.currentSourceSelection = uiContext.getCurrentSourceSelectionRef();
	this.currentCharacterRef = new DefaultReferenceFacade<>();
	this.currentDataSetRef = new DefaultReferenceFacade<>();
	this.actionMap = new PCGenActionMap(this, uiContext);
	this.characterTabs = new CharacterTabs(this);
	this.statusBar = new PCGenStatusBar(this);
	this.filenameListener = new FilenameListener();
	Observer messageObserver = new ShowMessageGuiObserver(this);
	ShowMessageDelegate.getInstance().addObserver(messageObserver);
	ChooserFactory.setDelegate(this);
	this.pcGenMenuBar = new PCGenMenuBar(this, uiContext);
	initComponents();
	pack();
	initSettings();
	Platform.runLater(() ->
		javaFXStage = new Stage()
	);
}
 
Example #5
Source File: CreatePullRequestModelTest.java    From azure-devops-intellij with MIT License 6 votes vote down vote up
@Before
public void setUp() {
    projectMock = Mockito.mock(Project.class);
    gitRepositoryMock = Mockito.mock(GitRepository.class);
    diffProviderMock = Mockito.mock(DiffCompareInfoProvider.class);
    observerMock = Mockito.mock(Observer.class);
    applicationProviderMock = Mockito.mock(CreatePullRequestModel.ApplicationProvider.class);
    currentBranch = PRGitObjectMockHelper.createLocalBranch("local");

    tfsRemote = new GitRemote("origin", Collections.singletonList("https://mytest.visualstudio.com/DefaultCollection/_git/testrepo"),
            Collections.singletonList("https://pushurl"), Collections.emptyList(), Collections.emptyList());

    when(diffProviderMock.getEmptyDiff(gitRepositoryMock)).thenCallRealMethod();
    when(gitRepositoryMock.getRemotes()).thenReturn(Collections.singletonList(tfsRemote));

    mockGitRepoBranches(currentBranch);
}
 
Example #6
Source File: NullClassLoader.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {

        System.err.println(
            "\nTest creating proxy class with the null class loader.\n");

        try {
            Class p = Proxy.getProxyClass(null,
                new Class[] { Runnable.class, Observer.class });
            System.err.println("proxy class: " + p);

            ClassLoader loader = p.getClassLoader();
            System.err.println("proxy class's class loader: " + loader);

            if (loader != null) {
                throw new RuntimeException(
                    "proxy class not defined in the null class loader");
            }

            System.err.println("\nTEST PASSED");

        } catch (Throwable e) {
            System.err.println("\nTEST FAILED:");
            e.printStackTrace();
            throw new RuntimeException("TEST FAILED: " + e.toString());
        }
    }
 
Example #7
Source File: LineWrappingTabPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected Composite doCreatePreviewPane(Composite composite, int numColumns) {

	super.doCreatePreviewPane(composite, numColumns);
	
	Composite previewLineWidthContainer= new Composite(composite, SWT.NONE);
	previewLineWidthContainer.setLayout(createGridLayout(2, false));
	
	final NumberPreference previewLineWidth= new NumberPreference(previewLineWidthContainer, 2, fPreviewPreferences, LINE_SPLIT,
	    0, 9999, FormatterMessages.LineWrappingTabPage_line_width_for_preview_label_text);
	fDefaultFocusManager.add(previewLineWidth);
	previewLineWidth.addObserver(fUpdater);
	previewLineWidth.addObserver(new Observer() {
		public void update(Observable o, Object arg) {
			fDialogSettings.put(PREF_PREVIEW_LINE_WIDTH, fPreviewPreferences.get(LINE_SPLIT));
		}
	});

	return composite;
}
 
Example #8
Source File: ClassImplementingObserverTest.java    From jdt2famix with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testInterface() {	
	Class observerClass = (Class) importer.types().named(Observer.class.getName());
	assertTrue(observerClass.getIsInterface());
	assertTrue(observerClass.getIsStub());
	assertEquals(observerClass.getContainer(), 
				 importer.namespaces().named(Observer.class.getPackage().getName()));
}
 
Example #9
Source File: HashCodeAndEqualsSafeSetTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void can_add_a_collection() throws Exception {
    HashCodeAndEqualsSafeSet mocks = HashCodeAndEqualsSafeSet.of(
            mock(UnmockableHashCodeAndEquals.class),
            mock(Observer.class));

    HashCodeAndEqualsSafeSet workingSet = new HashCodeAndEqualsSafeSet();

    workingSet.addAll(mocks);

    assertThat(workingSet.containsAll(mocks)).isTrue();
}
 
Example #10
Source File: Database.java    From PacketProxy with Apache License 2.0 5 votes vote down vote up
public <T,ID> Dao<T, ID> createTable(Class<T> c, Observer observer) throws Exception
{
	addObserver(observer);
	TableUtils.createTableIfNotExists(source, c);
	Dao<T, ID> dao = DaoManager.createDao(source, c);
	return dao;
}
 
Example #11
Source File: BoundingBoxWindow.java    From Pixie with MIT License 5 votes vote down vote up
/**
 * Allows another module to put an observer into the current module.
 *
 * @param o - the observer to be added
 */
public void addObserver(Observer o) {
    observable.addObserver(o);

    // notify to remove the gui key event dispatcher
    observable.notifyObservers(ObservedActions.Action.REMOVE_GUI_KEY_EVENT_DISPATCHER);
}
 
Example #12
Source File: CleanUpTabPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void internalRegisterSlavePreference(final CheckboxPreference master, final ButtonPreference[] slaves) {
   	master.addObserver( new Observer() {
   		public void update(Observable o, Object arg) {
   			for (int i= 0; i < slaves.length; i++) {
				slaves[i].setEnabled(master.getChecked());
			}
   		}
   	});

   	for (int i= 0; i < slaves.length; i++) {
		slaves[i].setEnabled(master.getChecked());
	}
}
 
Example #13
Source File: ModelEntity.java    From Robot-Overlord-App with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void getView(ViewPanel view) {
	view.pushStack("Mo","Model");

	// TODO FileNameExtensionFilter is Swing specific and should not happen here.
	ArrayList<FileFilter> filters = new ArrayList<FileFilter>();
	ServiceLoader<ModelLoadAndSave> loaders = ServiceLoader.load(ModelLoadAndSave.class);
	Iterator<ModelLoadAndSave> i = loaders.iterator();
	while(i.hasNext()) {
		ModelLoadAndSave loader = i.next();
		filters.add( new FileNameExtensionFilter(loader.getEnglishName(), loader.getValidExtensions()) );
	}
	view.addFilename(filename,filters);
	
	view.add(rotationAdjust);
	view.add(originAdjust);
	view.add(scale);
	
	Model m = this.model;
	if(m!=null) {
		view.add(numTriangles);
		view.add(hasNormals);
		view.add(hasColors);
		view.add(hasUVs);
	}

	ViewElementButton reloadButton = view.addButton("Reload");
	reloadButton.addObserver(new Observer() {
		@Override
		public void update(Observable o, Object arg) {
			reload();
		}
	});
	
	view.popStack();
	
	material.getView(view);
	
	super.getView(view);
}
 
Example #14
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 #15
Source File: DarkElvesCreatures.java    From stendhal with GNU General Public License v2.0 5 votes vote down vote up
private void buildSecretRoomArea(final StendhalRPZone zone) {
	Observer observer = new DrowObserver();
	for(CreatureRespawnPoint p:zone.getRespawnPointList()) {
		if(p!=null) {
			if(creatures.indexOf(p.getPrototypeCreature().getName())!=-1) {
				// it is our creature, will add observer now
				p.addObserver(observer);
			}
		}
	}
}
 
Example #16
Source File: NPCChatting.java    From stendhal with GNU General Public License v2.0 5 votes vote down vote up
/**
 * constructor
 * @param first - first npc (who strarting conversation)
 * @param second - second npc
 * @param conversations
 * @param explainations
 * @param n - observer n
 */
public NPCChatting(
		SpeakerNPC first,
		SpeakerNPC second,
		List<String> conversations,
		String explainations,
		Observer n) {
	this.first=first;
	this.second=second;
	this.conversations=conversations;
	this.explainations=explainations;
	this.next=n;

}
 
Example #17
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 #18
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 #19
Source File: ParameterizedConstructorInstantiatorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void should_fail_if_an_argument_instance_type_do_not_match_wanted_type() throws Exception {
    Observer observer = mock(Observer.class);
    Set wrongArg = mock(Set.class);
    given(resolver.resolveTypeInstances(Matchers.<Class<?>[]>anyVararg())).willReturn(new Object[]{ observer, wrongArg });

    try {
        new ParameterizedConstructorInstantiator(this, field("withMultipleConstructor"), resolver).instantiate();
        fail();
    } catch (MockitoException e) {
        assertThat(e.getMessage()).contains("argResolver").contains("incorrect types");
    }
}
 
Example #20
Source File: BaseEventTrackingService.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * Delete an observer of events.
 *
 * @param observer
 *        The class observing to delete.
 */
public void deleteObserver(Observer observer)
{
	m_observableHelper.deleteObserver(observer);
	m_priorityObservableHelper.deleteObserver(observer);
	m_localObservableHelper.deleteObserver(observer);
}
 
Example #21
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 #22
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 #23
Source File: MultiZonesFixedPath.java    From stendhal with GNU General Public License v2.0 5 votes vote down vote up
/**
 * constructor
 *
 * @param entity - pathnotifier owner
 * @param rt route
 * @param o Observer
 */
public MultiZonesFixedPath(final GuidedEntity entity, final List<RPZonePath> rt,
		final Observer o) {
	ent = entity;
	count = -1;
	route = rt;
	finishnotifier.setObserver(o);
}
 
Example #24
Source File: AbstractAdapter.java    From PracticalRecyclerView with Apache License 2.0 4 votes vote down vote up
void registerObserver(Observer observer) {
    dataSet.addObserver(observer);
}
 
Example #25
Source File: QmsHelper.java    From ForPDA with GNU General Public License v3.0 4 votes vote down vote up
public void subscribeQms(Observer observer) {
    qmsEvents.addObserver(observer);
}
 
Example #26
Source File: App.java    From ForPDA with GNU General Public License v3.0 4 votes vote down vote up
public void removeStatusBarSizeObserver(Observer observer) {
    statusBarSizeObservables.deleteObserver(observer);
}
 
Example #27
Source File: CustomTagFactory.java    From TranskribusCore with GNU General Public License v3.0 4 votes vote down vote up
public static void addObserver(Observer o) {
	registryObserver.addObserver(o);
}
 
Example #28
Source File: MockEventTrackingService.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public void addPriorityObserver(Observer observer)
{
	// TODO Auto-generated method stub

}
 
Example #29
Source File: VirtualMachineImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
void setDisposeObserver(Observer observer) {
   disposeObserver = observer;
}
 
Example #30
Source File: GaService.java    From GreenBits with GNU General Public License v3.0 4 votes vote down vote up
public void deleteNewBlockObserver(final Observer o) {
    mNewBlockObservable.deleteObserver(o);
}