当前位置: 首页>>代码示例>>Java>>正文


Java Optional类代码示例

本文整理汇总了Java中org.eclipse.e4.core.di.annotations.Optional的典型用法代码示例。如果您正苦于以下问题:Java Optional类的具体用法?Java Optional怎么用?Java Optional使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Optional类属于org.eclipse.e4.core.di.annotations包,在下文中一共展示了Optional类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: canExecute

import org.eclipse.e4.core.di.annotations.Optional; //导入依赖的package包/类
@CanExecute
public boolean canExecute(ESelectionService selectionService,
		@Optional @Named(PARAM_RESOURCE_TYPE) String resourceType) {
	Object s = selectionService.getSelection();
	if (resourceType == null) {
		return s != null && (s instanceof ECorpus || s instanceof EPipeline || s instanceof ETerminology);
	} else {
		if (resourceType.equals(EPipeline.class.getName()))
			return s != null && s instanceof EPipeline;
		else if (resourceType.equals(ECorpus.class.getName()))
			return s != null && s instanceof ECorpus;
		else if (resourceType.equals(ETerminology.class.getName()))
			return s != null && s instanceof ETerminology;
	}
	return false;
}
 
开发者ID:termsuite,项目名称:termsuite-ui,代码行数:17,代码来源:RemoveResourceHandler.java

示例2: reactOnCustomResourceChange

import org.eclipse.e4.core.di.annotations.Optional; //导入依赖的package包/类
@Inject
@Optional
public void reactOnCustomResourceChange( 
		LinguisticResourcesService lingueeService, 
		@Preference(value = TermSuiteUIPreferences.ACTIVATE_CUSTOM_RESOURCES) boolean active,
		@Preference(value = TermSuiteUIPreferences.LINGUISTIC_RESOURCES_DIRECTORY) String customResourcePath
		) {
	this.withCustomResources = active;
	if(active) {
		this.customResourcePath = customResourcePath;
		if(this.viewer != null)
			this.viewer.collapseToLevel(THE_RESOURCE_NODE, 0);
	}
	if(this.viewer != null)
		this.viewer.setInput(getRootNodes());
}
 
开发者ID:termsuite,项目名称:termsuite-ui,代码行数:17,代码来源:NavigatorPart.java

示例3: init

import org.eclipse.e4.core.di.annotations.Optional; //导入依赖的package包/类
@Inject @Optional
private void init(@UIEventTopic(TermSuiteEvents.EDITOR_INITIATED) Object part, MPart mPart) {
	if(this == part) {
		EPipeline pipeline = (EPipeline) context.get(TermSuiteUI.INPUT_OBJECT);
		this.pipelineValue.setValue(pipeline);
		this.context.set(EPipeline.class, pipeline);
		pipeline.eAdapters().add(new EContentAdapter() {
			public void notifyChanged(Notification notification) {
				super.notifyChanged(notification);
				if(notification.getFeature().equals(TermsuiteuiPackage.eINSTANCE.getEPipeline_Name())) {
					mPart.setLabel(notification.getNewStringValue());
				} else {
					// set dirty, unless this is a pipeline rename
					dirty.setDirty(true);
					validatePipeline();
				}
			}
		});
		validatePipeline();
	}
}
 
开发者ID:termsuite,项目名称:termsuite-ui,代码行数:22,代码来源:PipelinePart.java

示例4: execute

import org.eclipse.e4.core.di.annotations.Optional; //导入依赖的package包/类
@Execute
public void execute(
		@Optional @Named(IServiceConstants.ACTIVE_SHELL) Shell shell,
		@Optional TerminologyService terminologyService,
		@Optional ETerminology terminology,
		@Optional IndexedCorpus indexedCorpus
		) throws IOException {
	
	FileDialog fileDialog = new FileDialog(shell, SWT.SAVE);
	fileDialog.setText("Exporting terminology "+ TerminologyPart.toPartLabel(terminology) +" to " + formatName);
	String path = fileDialog.open();
	if(path != null) {
		if(withOptionDialog) {
			Dialog dialog = getDialog(shell);
			if(dialog.open() == Dialog.OK) 
				export(shell, terminology, getExporter(dialog), indexedCorpus, path);
		} else
			// no option dialog
			export(shell, terminology, getExporter(), indexedCorpus, path);
	}
}
 
开发者ID:termsuite,项目名称:termsuite-ui,代码行数:22,代码来源:ExportHandler.java

示例5: execute

import org.eclipse.e4.core.di.annotations.Optional; //导入依赖的package包/类
@Execute
public void execute(
		@Optional @Named(IServiceConstants.ACTIVE_SHELL) Shell shell,
		@Optional TerminologyService terminologyService,
		@Optional ETerminoViewerConfig viewerConfig,
		@Optional MPart terminologyPart
		) {
	EList<String> viewerList = viewerConfig.getSelectedPropertyNames();
	List<Property<?>> selectedProperties = viewerList
			.stream()
			.map(s -> PropertyUtil.forName(s)).collect(Collectors.toList());
	
	SelectPropertyDialog dialog = new SelectPropertyDialog(shell, selectedProperties, p-> true, false);
	if(dialog.open() == Dialog.OK) {
		List<String> propertyNames = dialog.getSelectedPropertyNames();
		viewerList.retainAll(propertyNames);
		propertyNames.removeAll(viewerList);
		viewerList.addAll(propertyNames);
	}
}
 
开发者ID:termsuite,项目名称:termsuite-ui,代码行数:21,代码来源:SelectTerminologyPropertiesHandler.java

示例6: execute

import org.eclipse.e4.core.di.annotations.Optional; //导入依赖的package包/类
@Execute
public void execute(ParameterizedCommand command, 
		@Optional @Named(IServiceConstants.ACTIVE_SELECTION) EPipeline selectedPipeline,
		@Named(IServiceConstants.ACTIVE_SHELL) Shell shell,
		NLPService extractorService,
		ResourceService resourceService) {
	Map<String, Object> parameterMap = command.getParameterMap();
	boolean useCache = parameterMap.containsKey(TermSuiteUI.COMMAND_RUN_PIPELINE_PARAMETER_USE_CACHE)
			&& Boolean.parseBoolean((String) parameterMap.get(TermSuiteUI.COMMAND_RUN_PIPELINE_PARAMETER_USE_CACHE));
	if(!parameterMap.containsKey(TermSuiteUI.COMMAND_RUN_PIPELINE_PARAMETER_PIPELINE_ID)
			&& selectedPipeline != null) {
		// run handler from selected pipeline
		runPipeline(shell, extractorService, resourceService, selectedPipeline, useCache);
	} else {
		// run handler from parameterized command
		String pipelineName = parameterMap.get(TermSuiteUI.COMMAND_RUN_PIPELINE_PARAMETER_PIPELINE_ID).toString();
		java.util.Optional<EPipeline> pipeline = resourceService.getPipeline(pipelineName);
		if(pipeline.isPresent()) 
			runPipeline(shell, extractorService, resourceService, pipeline.get(), useCache);
	}
}
 
开发者ID:termsuite,项目名称:termsuite-ui,代码行数:22,代码来源:RunPipelineHandler.java

示例7: canExecute

import org.eclipse.e4.core.di.annotations.Optional; //导入依赖的package包/类
@CanExecute
public boolean canExecute(
		@Optional ParameterizedCommand command, 
		@Optional @Named(IServiceConstants.ACTIVE_SELECTION) EPipeline selectedPipeline,
		ResourceService resourceService,
		NLPService extractorService) {
	if(command == null || command.getParameterMap().isEmpty()) {
		// try to run handler from selected EPipeline
		if(selectedPipeline != null)
			return extractorService.isPipelineValid(selectedPipeline);
		else 
			return false;
	} else {
		// try to run handler from parameterized command
		Map<String, Object> parameterMap = command.getParameterMap();
		Object pipelineName = parameterMap.get(TermSuiteUI.COMMAND_RUN_PIPELINE_PARAMETER_PIPELINE_ID);
		return pipelineName != null
					&& resourceService.getPipeline(pipelineName.toString()).isPresent()
					&& extractorService.isPipelineValid(resourceService.getPipeline(pipelineName.toString()).get())
					;
	}
}
 
开发者ID:termsuite,项目名称:termsuite-ui,代码行数:23,代码来源:RunPipelineHandler.java

示例8: updateUIWithClientIdAndConnectionStatus

import org.eclipse.e4.core.di.annotations.Optional; //导入依赖的package包/类
@Inject
@Optional
public void updateUIWithClientIdAndConnectionStatus(@UIEventTopic(CONNECTED_EVENT_TOPIC) final Object message) {
	if (message instanceof Object[]) {
		this.uiSynchronize.asyncExec(new Runnable() {
			@Override
			public void run() {
				PublishPart.this.textRequesterClientId.setText(((Object[]) message)[1].toString());
				PublishPart.this.textRequestId.setText(generateRequestId());
				PublishPart.this.form.setImage(
						PublishPart.this.bundleResourceService.loadImage(this.getClass(), ONLINE_STATUS_IMAGE));
				setTootipConnectionStatus(PublishPart.this.uiSynchronize, PublishPart.this.buttonPublish,
						((Object[]) message)[0].toString(), true);
				mqttClient = (IKuraMQTTClient) ((Object[]) message)[2];
			}
		});
	}
}
 
开发者ID:amitjoy,项目名称:Kura-MQTT-Client-Utility,代码行数:19,代码来源:PublishPart.java

示例9: subscribeToPositionTreeRemoveTopic

import org.eclipse.e4.core.di.annotations.Optional; //导入依赖的package包/类
@Inject
@Optional
public void subscribeToPositionTreeRemoveTopic(
		@UIEventTopic(OrderServiceEvents.TOPIC_POSITION_TREE_REMOVE) final PositionWithOrderAndArticleInfoDTO deletedPosition) {
	OrderId orderIdInTreeLoaded = deletedPosition.getOrderId();
	if (cachedPositions.containsKey(orderIdInTreeLoaded)) {
		OrderPositionsTreeviewDTO children = cachedPositions.get(orderIdInTreeLoaded);
		if (!children.removePosition(deletedPosition.getPosition())) {
			LOGGER.info("Position " + deletedPosition + " in OrderTreeView already removed."
					+ " You are firing too many events!");
		} else {
			LOGGER.info("Position " + deletedPosition.getPosition() + " from OrderTreeView removed.");
		}
		viewer.refresh(deletedPosition.getOrder(), false);
	}
}
 
开发者ID:scenarioo,项目名称:scenarioo-example-swtbot-e4,代码行数:17,代码来源:OrdersOverviewPart.java

示例10: execute

import org.eclipse.e4.core.di.annotations.Optional; //导入依赖的package包/类
@Execute
public void execute(
		@Optional @Named(IServiceConstants.ACTIVE_SELECTION) Object selection,
		CorpusCommandController commandController, @Optional @Active MPart activePart,
		final Shell shell) {
	if (selection instanceof BTSDBBaseObject) {
		if (MessageDialog.openConfirm(shell,
				"Confirm deletion",
				"Object will not be recoverable after deletion. Proceed?")) {
			commandController.deleteFromDB((BTSDBBaseObject) selection);
			if (activePart != null)
			{
				Object o = activePart.getObject();
				if (o instanceof StructuredViewerProvider)
				{
					StructuredViewerProvider viewerProvider = (StructuredViewerProvider) o;
					viewerProvider.getActiveStructuredViewer().refresh();
				}
			}
		}
	}
}
 
开发者ID:cplutte,项目名称:bts,代码行数:23,代码来源:DeletePermanentlyHandler.java

示例11: run

import org.eclipse.e4.core.di.annotations.Optional; //导入依赖的package包/类
@Inject
	@Optional
	void eventReceivedCaretEvents(
			@EventTopic("event_text_selection/*") final Object event) {
		System.out.println("lemma editor event received: " + event);
		if (selectedLemmaEntry !=null && event instanceof String && event != null) {
//			setTextSelectionEvent((String) event);
			
			sync.asyncExec(new Runnable() {
				public void run() {
					signTextEditor.setTextSelectionEvent((String) event);
				}
			});

		}
	}
 
开发者ID:cplutte,项目名称:bts,代码行数:17,代码来源:EgyLemmaEditorPart.java

示例12: receiveSelection

import org.eclipse.e4.core.di.annotations.Optional; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Inject
@Optional
void receiveSelection(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) Object selection) {
	if (selection != null) {
		List<BTSObject> sel;
		if (selection instanceof List<?>) {
			sel = (List<BTSObject>)selection;
		} else {		
			sel = new Vector<BTSObject>();
			if (selection instanceof BTSObject[]) {
				sel.addAll(Arrays.asList((BTSObject[])selection));
			} else if (selection instanceof BTSObject)
				sel.add((BTSObject)selection);
		}
		appendToHistory(sel);
	}
}
 
开发者ID:cplutte,项目名称:bts,代码行数:19,代码来源:BTSSelectionHistoryServiceImpl.java

示例13: eventReceivedRelatingObjectsLoadedEvents

import org.eclipse.e4.core.di.annotations.Optional; //导入依赖的package包/类
/**
 * Event received relating objects loaded events.
 *
 * @param event the event
 */
@SuppressWarnings({ "restriction", "rawtypes" })
@Inject
@Optional
void eventReceivedRelatingObjectsLoadedEvents(
		@EventTopic("event_relating_objects/*") Object event) {

	if (event != null && event instanceof List) {
		List<BTSObject> annotations = new Vector<BTSObject>(
				((List) event).size());
		for (Object o : (List) event) {
			if (o instanceof BTSObject) {
				if (o != null) {
					annotations.add((BTSObject) o);
				}
			}
		}
		if (!annotations.isEmpty()) {
			processSelection(annotations);
		}
	}
}
 
开发者ID:cplutte,项目名称:bts,代码行数:27,代码来源:TextAnnotationsPart.java

示例14: eventReceivedPreferencesChanged

import org.eclipse.e4.core.di.annotations.Optional; //导入依赖的package包/类
@Inject
@Optional
void eventReceivedPreferencesChanged(
		@EventTopic("event_preferences_changed/*") final String preferencePath) {
	if (preferencePath != null && preferencePath.endsWith(BTSCorpusConstants.PREF_ANNOTATION_SETTINGS)) {
		
		sync.asyncExec(new Runnable() {
			@Override
			public void run() {
				Preferences rootNode = ConfigurationScope.INSTANCE.getNode("org.bbaw.bts.ui.corpus");
				annotationSettings = (EclipsePreferences) rootNode.node(BTSCorpusConstants.PREF_ANNOTATION_SETTINGS);
				AnnotationToolbarItemCreator.processAndUpateToolbarItemsAnnotationShortcut(part, annotationSettings);
				textAnnotatationEditor.reloadCurrentSentence();
			}
		});
		
	}
}
 
开发者ID:cplutte,项目名称:bts,代码行数:19,代码来源:TextAnnotationsPart.java

示例15: run

import org.eclipse.e4.core.di.annotations.Optional; //导入依赖的package包/类
@Inject
	@Optional
	void eventReceivedRelatingObjectsLoadedEvents(
			@EventTopic("event_text_relating_objects/*") final BTSRelatingObjectsLoadingEvent event) {
		if (!(event.getObject() instanceof BTSText)) return;
		
		text = (BTSText) event.getObject();
		queryId = "relations.objectId-" + text.get_id();
		if (event != null) {
			sync.syncExec(new Runnable() {
				public void run() {
					// TODO update annotations!!!!!
//					loadRelatingObjects(event);
				}
			});

		}
	}
 
开发者ID:cplutte,项目名称:bts,代码行数:19,代码来源:TextAnnotationsPart.java


注:本文中的org.eclipse.e4.core.di.annotations.Optional类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。