org.eclipse.e4.core.di.annotations.Optional Java Examples

The following examples show how to use org.eclipse.e4.core.di.annotations.Optional. 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: PreferenceInitializerAddon.java    From saneclipse with Eclipse Public License 1.0 6 votes vote down vote up
@Inject
@Optional
public void name(@UIEventTopic(UIEvents.UILifeCycle.ACTIVATE) Event event) {
	if(!preferencesInitialized) {
		preferencesInitialized = true;
		configureJDTUi();
		configureJDTCore();
		configurePDEUi();
		configureIde();
		configureWorkbench();
		configurePerformanceMonitoring();
		configureDebug();
		configureEditor();
		configureXMLEditor();
		configureMemoryMonitorActive();
	}
}
 
Example #2
Source File: MedicationView.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
@Optional
@Inject
void updatePrescription(
	@UIEventTopic(ElexisEventTopics.EVENT_UPDATE) IPrescription prescription){
	if (CoreUiUtil.isActiveControl(tpc)) {
		if (prescription != null) {
			if (!getMedicationComposite().isShowingHistory()) {
				EntryType entryType = prescription.getEntryType();
				if (entryType == EntryType.RECIPE || entryType == EntryType.SELF_DISPENSED) {
					return;
				}
			}
			updateUi(prescription.getPatient(), true);
		}
	}
}
 
Example #3
Source File: AccountsPart.java    From offspring with MIT License 6 votes vote down vote up
@Inject
@Optional
private void onAccountUpdateBalance(
    @UIEventTopic(INxtService.TOPIC_ACCOUNT_UPDATE_BALANCE) IAccount account,
    IUserService userService) {

  IUser active = userService.getActiveUser();
  if (active != null) {

    IUser user = userService.getUser(account);
    if (user != null) {
      AccountButtonComposite c = findAccountButtonComposite(user);
      if (c != null) {
        c.setBalance(account.getBalance(), account.getUnconfirmedBalance());
      }
      if (user.equals(active)) {
        setActiveUserBalance(account.getBalance());
      }
    }
  }
  updateTotalBalance();
}
 
Example #4
Source File: StatusBar.java    From offspring with MIT License 6 votes vote down vote up
@Inject
@Optional
private void onPeerEvent(@UIEventTopic(INxtService.TOPIC_PEER) Peer peer) {
  if (peersText != null && !peersText.isDisposed()) {
    int active = nxt.getAllConnectedPeers().size();
    int known = nxt.getAllWellknownPeers().size();
    int blacklisted = nxt.getAllBlacklistedPeers().size();

    peersText.setText(createPeerText(active, known, blacklisted));
    peersText.pack();

    long downloadVolume = 0;
    long uploadVolume = 0;
    for (Peer p : nxt.getAllConnectedPeers()) {
      downloadVolume += p.getDownloadedVolume();
      uploadVolume += p.getUploadedVolume();
    }
    downloadsText.setText(createDownloadsText(downloadVolume, uploadVolume));
    downloadsText.pack();

    mainComposite.layout();
  }
}
 
Example #5
Source File: CoreUiUtil.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
@Inject
@Optional
public void subscribeAppStartupComplete(
	@UIEventTopic(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE) Event event, UISynchronize sync){
	
	synchronized (lock) {
		Object property = event.getProperty("org.eclipse.e4.data");
		if (property instanceof MApplication) {
			MApplication application = (MApplication) property;
			// A RAP application has one application context per client
			// the resp. context service implementation considers this
			contextService.getRootContext().setNamed("applicationContext",
				application.getContext());
			
			if (!delayedInjection.isEmpty()) {
				for (Object object : delayedInjection) {
					sync.asyncExec(() -> {
						injectServices(object);
					});
				}
				delayedInjection.clear();
			}
		}
	}
}
 
Example #6
Source File: FaelleView.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
@Optional
@Inject
void compatitbility(
	@UIEventTopic(ElexisEventTopics.PERSISTENCE_EVENT_COMPATIBILITY + "*") Object object){
	if (object instanceof ICoverage
		|| (object instanceof Class && object.equals(ICoverage.class))) {
		// refresh from database if modified by po
		if (actPatient != null) {
			if (object instanceof ICoverage) {
				CoreModelServiceHolder.get().refresh((ICoverage) object, true);
			}
			CoreModelServiceHolder.get().refresh(actPatient, true);
		}
		refreshTableViewer();
	}
}
 
Example #7
Source File: KonsListe.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Optional
@Inject
void changedCoverage(@UIEventTopic(ElexisEventTopics.BASE_MODEL + "*") ICoverage iCoverage){
	if (iCoverage != null) {
		actPatient = iCoverage.getPatient();
		restart(false);
	}
}
 
Example #8
Source File: SamplePart.java    From e4Preferences with Eclipse Public License 1.0 5 votes vote down vote up
@Inject
@Optional
public void reactOnPrefColorChange(@Preference(value = "prefColor") String colorKey)
{
	System.out.println("React on a change in preferences with colorkey = " + colorKey);
	if ((colorKey != null) && (tableViewer != null) && !tableViewer.getControl().isDisposed())
	{
		Color c = getColorFromPref(colorKey);

		tableViewer.getTable().setForeground(c);
		tableViewer.getTable().redraw();
	}
}
 
Example #9
Source File: VerrechnungsDisplay.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Optional
@Inject
public void udpateEncounter(@UIEventTopic(ElexisEventTopics.EVENT_UPDATE) IEncounter encounter){
	if (encounter != null && encounter.equals(actEncounter)) {
		setEncounter(actEncounter);
	}
}
 
Example #10
Source File: KonsDetailView.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Inject
void lockPreRelease(
	@Optional @UIEventTopic(ElexisEventTopics.EVENT_LOCK_PRERELEASE) IEncounter encounter){
	if (created) {
		if (encounter.equals(actEncounter)) {
			save();
		}
	}
}
 
Example #11
Source File: MedicationView.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Inject
void reloadPrescription(
	@Optional @UIEventTopic(ElexisEventTopics.EVENT_CREATE) Class<?> clazz){
	if (clazz == IPrescription.class) {
		if (CoreUiUtil.isActiveControl(tpc)) {
			ContextServiceHolder.get().getActivePatient().ifPresent(patient -> {
				updateUi(patient, false);
			});
		}
	}
}
 
Example #12
Source File: KonsDetailView.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Inject
void unlockedEncounter(
	@Optional @UIEventTopic(ElexisEventTopics.EVENT_LOCK_RELEASED) IEncounter encounter){
	if (created) {
		if (encounter.equals(actEncounter)) {
			setUnlocked(false);
		}
	}
}
 
Example #13
Source File: PatientenListeView.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Inject
void changedMandator(
	@Optional @UIEventTopic(ElexisEventTopics.EVENT_USER_CHANGED) IUser user){
	if (created) {
		Display.getDefault().asyncExec(() -> {
			userChanged();
		});
	}
}
 
Example #14
Source File: KonsListe.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Optional
@Inject
void compatitbility(
	@UIEventTopic(ElexisEventTopics.PERSISTENCE_EVENT_COMPATIBILITY + "*") Object object){
	if (object instanceof IEncounter
		|| (object instanceof Class && object.equals(IEncounter.class))) {
		// refresh from database if modified by po
		if (object instanceof IEncounter) {
			IEncounter encounter = (IEncounter) object;
			CoreModelServiceHolder.get().refresh(encounter, true);
			CoreModelServiceHolder.get().refresh(encounter.getCoverage(), true);
		}
		restart(true);
	}
}
 
Example #15
Source File: CoreUiUtil.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private static java.util.Optional<IEclipseContext> getApplicationContext(){
	if (contextService == null) {
		return java.util.Optional.empty();
	}
	return java.util.Optional.ofNullable((IEclipseContext) contextService.getRootContext()
		.getNamed("applicationContext").orElse(null));
}
 
Example #16
Source File: EigenartikelDetailDisplay.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Inject
public void selection(
	@Optional @Named("ch.elexis.core.ui.eigenartikel.selection") IArticle typedArticle){
	if (epc != null && !epc.isDisposed()) {
		display(typedArticle);
	}
}
 
Example #17
Source File: VerrechnungsDisplay.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Optional
@Inject
public void udpateBilled(
	@UIEventTopic(ElexisEventTopics.EVENT_UPDATE) IBilled billed){
	if (billed != null && viewer != null && viewer.getTable() != null
		&& !viewer.getTable().isDisposed()) {
		viewer.update(billed, null);
	}
}
 
Example #18
Source File: FixMediDisplay.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public void reload(){
	if (!isDisposed()) {
		clear();
		java.util.Optional<IPatient> patient = ContextServiceHolder.get().getActivePatient();
		if (patient.isPresent()) {
			List<IPrescription> fix =
				patient.get().getMedication(Arrays.asList(EntryType.FIXED_MEDICATION));
			fix.stream().forEach(p -> add(p));
			
			lCost.setText(MedicationViewHelper.calculateDailyCostAsString(fix));
			interactionLink.updateAtcs(MedicationViewHelper.getAllGtins(fix));
		}
		sortList();
	}
}
 
Example #19
Source File: MySellOrdersPart.java    From offspring with MIT License 5 votes vote down vote up
@Inject
@Optional
private void onActiveUserChanged(
    @UIEventTopic(IUserService.TOPIC_ACTIVEUSER_CHANGED) IUser user) {
  if (viewer != null && !viewer.getControl().isDisposed()) {
    viewer.refresh();
  }
}
 
Example #20
Source File: MyBuyOrdersPart.java    From offspring with MIT License 5 votes vote down vote up
@Inject
@Optional
private void onAssetSelected(
    @UIEventTopic(IAssetExchange.TOPIC_ASSET_SELECTED) Asset asset) {
  if (viewer != null && !viewer.getControl().isDisposed()) {
    viewer.refresh();
  }
}
 
Example #21
Source File: MyBuyOrdersPart.java    From offspring with MIT License 5 votes vote down vote up
@Inject
@Optional
public void partActivation(
    @UIEventTopic(UIEvents.UILifeCycle.ACTIVATE) Event event) {
  if (viewer != null && !viewer.getControl().isDisposed()) {
    viewer.refresh();
  }
}
 
Example #22
Source File: MyBuyOrdersPart.java    From offspring with MIT License 5 votes vote down vote up
@Inject
@Optional
private void onActiveUserChanged(
    @UIEventTopic(IUserService.TOPIC_ACTIVEUSER_CHANGED) IUser user) {
  if (viewer != null && !viewer.getControl().isDisposed()) {
    viewer.refresh();
  }
}
 
Example #23
Source File: EigendiagnoseSelector.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Inject
@Optional
public void reload(@UIEventTopic(ElexisEventTopics.EVENT_RELOAD) Class<?> clazz){
	if (IDiagnosisTree.class.equals(clazz)) {
		if (commonViewer != null && !commonViewer.isDisposed()) {
			commonViewer.getViewerWidget().refresh();
		}
	}
}
 
Example #24
Source File: AssetsPart.java    From offspring with MIT License 5 votes vote down vote up
@Inject
@Optional
private void onAssetSelected(
    @UIEventTopic(IAssetExchange.TOPIC_ASSET_SELECTED) Asset asset) {
  if (assetsViewer != null && !assetsViewer.getControl().isDisposed()) {
    IStructuredSelection selection = (IStructuredSelection) assetsViewer
        .getSelection();
    Object selectedAsset = selection.getFirstElement();
    if (selectedAsset instanceof Asset && asset instanceof Asset) {
      if (!selectedAsset.equals(asset)) {
        assetsViewer.setSelection(new StructuredSelection(asset));
      }
    }
  }
}
 
Example #25
Source File: AssetsPart.java    From offspring with MIT License 5 votes vote down vote up
@Inject
@Optional
private void onInitializationFinished(
    @UIEventTopic(INxtService.TOPIC_INITIALIZATION_FINISHED) int dummy) {
  if (assetsViewer != null && !assetsViewer.getControl().isDisposed()) {
    assetsViewer.refresh();
  }
}
 
Example #26
Source File: AskOrdersPart.java    From offspring with MIT License 5 votes vote down vote up
@Inject
@Optional
private void onAssetSelected(
    @UIEventTopic(IAssetExchange.TOPIC_ASSET_SELECTED) Asset asset) {
  if (ordersViewer != null && !ordersViewer.getControl().isDisposed()) {
    ordersViewer.setInput(asset.getId());
    ordersViewer.refresh();
  }
}
 
Example #27
Source File: MyAssetsPart.java    From offspring with MIT License 5 votes vote down vote up
@Inject
@Optional
public void partActivation(
    @UIEventTopic(UIEvents.UILifeCycle.ACTIVATE) Event event) {
  if (viewer != null && !viewer.getControl().isDisposed()) {
    viewer.refresh();
  }
}
 
Example #28
Source File: MyAssetsPart.java    From offspring with MIT License 5 votes vote down vote up
@Inject
@Optional
private void onActiveUserChanged(
    @UIEventTopic(IUserService.TOPIC_ACTIVEUSER_CHANGED) IUser user) {
  if (viewer != null && !viewer.getControl().isDisposed()) {
    viewer.refresh();
  }
}
 
Example #29
Source File: MySellOrdersPart.java    From offspring with MIT License 5 votes vote down vote up
@Inject
@Optional
private void onAssetSelected(
    @UIEventTopic(IAssetExchange.TOPIC_ASSET_SELECTED) Asset asset) {
  if (viewer != null && !viewer.getControl().isDisposed()) {
    viewer.refresh();
  }
}
 
Example #30
Source File: BlockSelector.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Optional
@Inject
public void udpateBlock(
	@UIEventTopic(ElexisEventTopics.EVENT_UPDATE) ICodeElementBlock block){
	if (block != null && cv != null && cv.getViewerWidget() != null
		&& !cv.getViewerWidget().getControl().isDisposed()) {
		BlockTreeViewerItem item = blockItemMap.get(block);
		cv.getViewerWidget().refresh(item, true);
	}
}