本文整理汇总了Java中org.eclipse.che.ide.api.action.Presentation类的典型用法代码示例。如果您正苦于以下问题:Java Presentation类的具体用法?Java Presentation怎么用?Java Presentation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Presentation类属于org.eclipse.che.ide.api.action包,在下文中一共展示了Presentation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PaneMenuActionItemWidget
import org.eclipse.che.ide.api.action.Presentation; //导入依赖的package包/类
public PaneMenuActionItemWidget(@NotNull Action action) {
initWidget(UI_BINDER.createAndBindUi(this));
this.action = action;
Presentation presentation = action.getTemplatePresentation();
title.setText(presentation.getText());
addDomHandler(
new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if (delegate != null) {
delegate.onItemClicked(PaneMenuActionItemWidget.this);
}
}
},
ClickEvent.getType());
}
示例2: renderAction
import org.eclipse.che.ide.api.action.Presentation; //导入依赖的package包/类
private Node renderAction(String title, final Action action) {
final Presentation presentation = presentationFactory.getPresentation(action);
Element divElement = Elements.createDivElement(style.listElement());
divElement.addEventListener(
"click",
new EventListener() {
@Override
public void handleEvent(Event evt) {
ActionEvent event = new ActionEvent(presentation, actionManager);
action.actionPerformed(event);
}
},
true);
divElement.getStyle().setCursor("pointer");
divElement.getStyle().setColor(Style.getOutputLinkColor());
Element label = Elements.createDivElement(style.actionLabel());
label.setInnerText(title);
divElement.appendChild(label);
String hotKey =
KeyMapUtil.getShortcutText(keyBindingAgent.getKeyBinding(actionManager.getId(action)));
if (hotKey == null) {
hotKey = " ";
} else {
hotKey = "<nobr> " + hotKey + " </nobr>";
}
SpanElement hotKeyElement = Elements.createSpanElement(style.hotKey());
hotKeyElement.setInnerHTML(hotKey);
divElement.appendChild(hotKeyElement);
return divElement;
}
示例3: updateActions
import org.eclipse.che.ide.api.action.Presentation; //导入依赖的package包/类
protected ActionGroup updateActions() {
final ActionGroup mainActionGroup = (ActionGroup) actionManager.getAction(getGroupMenu());
if (mainActionGroup == null) {
return new DefaultActionGroup(actionManager);
}
final Action[] children = mainActionGroup.getChildren(null);
for (final Action action : children) {
final Presentation presentation = presentationFactory.getPresentation(action);
// pass into action properties
presentation.putClientProperty(CURRENT_FILE_PROP, editorTab.getFile());
presentation.putClientProperty(CURRENT_TAB_PROP, editorTab);
presentation.putClientProperty(CURRENT_PANE_PROP, editorPartStack);
}
return super.updateActions();
}
示例4: onItemClicked
import org.eclipse.che.ide.api.action.Presentation; //导入依赖的package包/类
@Override
public void onItemClicked(@NotNull EditorPaneMenuItem<Action> item) {
editorPaneMenu.hide();
final Action action = item.getData();
final Presentation presentation = presentationFactory.getPresentation(action);
presentation.putClientProperty(CURRENT_PANE_PROP, EditorPartStackPresenter.this);
final PartPresenter activePart = getActivePart();
final TabItem tab = getTabByPart(activePart);
if (tab != null) {
final VirtualFile virtualFile = ((EditorTab) tab).getFile();
// pass into action file property and editor tab
presentation.putClientProperty(CURRENT_TAB_PROP, tab);
presentation.putClientProperty(CURRENT_FILE_PROP, virtualFile);
}
action.actionPerformed(new ActionEvent(presentation, actionManager, null));
}
示例5: MenuBarItem
import org.eclipse.che.ide.api.action.Presentation; //导入依赖的package包/类
public MenuBarItem(
ActionGroup group,
ActionManager actionManager,
Provider<PerspectiveManager> managerProvider,
PresentationFactory presentationFactory,
Element element,
ActionSelectedHandler handler,
KeyBindingAgent keyBindingAgent,
MenuResources.Css css) {
this.group = group;
this.actionManager = actionManager;
this.managerProvider = managerProvider;
this.presentationFactory = presentationFactory;
this.element = element;
this.actionSelectedHandler = handler;
this.keyBindingAgent = keyBindingAgent;
this.css = css;
Presentation presentation = presentationFactory.getPresentation(group);
title = presentation.getText();
element.setInnerText(presentation.getText());
setEnabled(Utils.hasVisibleChildren(group, presentationFactory, actionManager));
}
示例6: onPropertyChange
import org.eclipse.che.ide.api.action.Presentation; //导入依赖的package包/类
@Override
public void onPropertyChange(PropertyChangeEvent e) {
String propertyName = e.getPropertyName();
if (Presentation.PROP_TEXT.equals(propertyName)) {
if (tooltip != null && e.getNewValue() instanceof String) {
tooltip.setTitle((String) e.getNewValue());
}
} else if (Presentation.PROP_ENABLED.equals(propertyName)) {
setEnabled((Boolean) e.getNewValue());
} else if (Presentation.PROP_ICON.equals(propertyName)) {
renderImage();
} else if (Presentation.PROP_VISIBLE.equals(propertyName)) {
setVisible((Boolean) e.getNewValue());
} else if (SELECTED_PROPERTY_NAME.equals(propertyName)) {
setSelected((Boolean) e.getNewValue());
}
}
示例7: onPropertyChange
import org.eclipse.che.ide.api.action.Presentation; //导入依赖的package包/类
@Override
public void onPropertyChange(PropertyChangeEvent e) {
String propertyName = e.getPropertyName();
if (Presentation.PROP_TEXT.equals(propertyName)) {
if (tooltip != null && e.getNewValue() instanceof String) {
tooltip.setTitle((String) e.getNewValue());
}
} else if (Presentation.PROP_ENABLED.equals(propertyName)) {
setEnabled((Boolean) e.getNewValue());
} else if (Presentation.PROP_ICON.equals(propertyName)) {
renderImage();
} else if (Presentation.PROP_VISIBLE.equals(propertyName)) {
setVisible((Boolean) e.getNewValue());
} else if (SELECTED_PROPERTY_NAME.equals(propertyName)) {
setSelected((Boolean) e.getNewValue());
}
}
示例8: updateInPerspective
import org.eclipse.che.ide.api.action.Presentation; //导入依赖的package包/类
@Override
public void updateInPerspective(ActionEvent event) {
EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
Presentation presentation = event.getPresentation();
if (activeEditor != workspaceAgent.getActivePart()) {
presentation.setEnabledAndVisible(false);
return;
}
if (Objects.nonNull(activeEditor) && activeEditor instanceof TextEditor) {
TextEditorConfiguration configuration = ((TextEditor) activeEditor).getConfiguration();
if (configuration instanceof LanguageServerEditorConfiguration) {
ServerCapabilities capabilities =
((LanguageServerEditorConfiguration) configuration).getServerCapabilities();
presentation.setEnabledAndVisible(
capabilities.getRenameProvider() != null && capabilities.getRenameProvider());
return;
}
}
presentation.setEnabledAndVisible(false);
}
示例9: updateActions
import org.eclipse.che.ide.api.action.Presentation; //导入依赖的package包/类
@Override
protected ActionGroup updateActions() {
ActionGroup actionGroup = super.updateActions();
for (Action action : actionGroup.getChildren(null)) {
Presentation presentation = action.getTemplatePresentation();
presentation.putClientProperty(BREAKPOINT, breakpoint);
}
return actionGroup;
}
示例10: shouldBeVisibleOnUpdate
import org.eclipse.che.ide.api.action.Presentation; //导入依赖的package包/类
@Test
public void shouldBeVisibleOnUpdate() {
String confName = "test_conf";
when(debugConfiguration.getName()).thenReturn(confName);
DebugConfiguration configuration = mock(DebugConfiguration.class);
Optional<DebugConfiguration> configurationOptional = mock(Optional.class);
when(configurationOptional.isPresent()).thenReturn(Boolean.TRUE);
when(configurationOptional.get()).thenReturn(configuration);
when(debugConfigurationsManager.getCurrentDebugConfiguration())
.thenReturn(configurationOptional);
ActionEvent event = mock(ActionEvent.class);
Presentation presentation = mock(Presentation.class);
when(event.getPresentation()).thenReturn(presentation);
action.updateInPerspective(event);
verify(presentation).setEnabledAndVisible(true);
}
示例11: performAction
import org.eclipse.che.ide.api.action.Presentation; //导入依赖的package包/类
@Override
public void performAction(String actionId, Map<String, String> parameters) {
final Action action;
if (actionId != null && (action = getAction(actionId)) != null) {
final Presentation presentation = presentationFactory.getPresentation(action);
final ActionEvent actionEvent = new ActionEvent(presentation, this, parameters);
action.update(actionEvent);
if (presentation.isEnabled() && presentation.isVisible()) {
action.actionPerformed(actionEvent);
}
}
}
示例12: render
import org.eclipse.che.ide.api.action.Presentation; //导入依赖的package包/类
@Override
public void render(Element itemElement, Action itemData) {
TableCellElement icon = Elements.createTDElement(css.proposalIcon());
TableCellElement label = Elements.createTDElement(css.proposalLabel());
TableCellElement group = Elements.createTDElement(css.proposalGroup());
Presentation presentation = presentationFactory.getPresentation(itemData);
itemData.update(new ActionEvent(presentation, actionManager));
if (presentation.getImageElement() != null) {
ElementWidget image = new ElementWidget(presentation.getImageElement());
image.getElement().setAttribute("class", toolbarResources.toolbar().iconButtonIcon());
image.getElement().getStyle().setMargin(0, Style.Unit.PX);
icon.appendChild((Node) image.getElement());
} else if (presentation.getHTMLResource() != null) {
icon.setInnerHTML(presentation.getHTMLResource());
}
String hotKey =
KeyMapUtil.getShortcutText(
keyBindingAgent.getKeyBinding(actionManager.getId(itemData)));
if (hotKey == null) {
hotKey = " ";
} else {
hotKey = "<nobr> [" + hotKey + "] </nobr>";
}
label.setInnerHTML(presentation.getText() + hotKey);
if (!presentation.isEnabled() || !presentation.isVisible()) {
itemElement.getStyle().setProperty("opacity", "0.6");
}
String groupName = actions.get(itemData);
if (groupName != null) {
group.setInnerHTML(groupName);
}
itemElement.appendChild(icon);
itemElement.appendChild(label);
itemElement.appendChild(group);
}
示例13: addToPanel
import org.eclipse.che.ide.api.action.Presentation; //导入依赖的package包/类
/** Create a new widget and add it to panel menu. */
private void addToPanel(FlowPanel panel, Action action, PresentationFactory presentationFactory) {
Presentation presentation = presentationFactory.getPresentation(action);
if (action instanceof Separator) {
panel.add(new SeparatorItem(resources.menuCss().panelSeparator()));
// todo find way to render non custom actions
} else if (action instanceof CustomComponentAction) {
CustomComponentAction customComponentAction = (CustomComponentAction) action;
Widget component = customComponentAction.createCustomComponent(presentation);
component.addStyleName(resources.menuCss().customComponent());
panel.add(component);
}
}
示例14: expandActionGroup
import org.eclipse.che.ide.api.action.Presentation; //导入依赖的package包/类
private void expandActionGroup(
List<Action> newVisibleActions, ActionManager actionManager, ActionGroup mainActionGroup) {
final Action[] children = mainActionGroup.getChildren(null);
for (final Action action : children) {
final Presentation presentation = presentationFactory.getPresentation(action);
final ActionEvent e = new ActionEvent(presentation, actionManager);
action.update(e);
if (presentation.isVisible()) { // add only visible items
newVisibleActions.add(action);
}
if (action2barItem.containsKey(action)) {
action2barItem.get(action).update();
}
}
}
示例15: actionShouldBePerformed
import org.eclipse.che.ide.api.action.Presentation; //导入依赖的package包/类
@Test
public void actionShouldBePerformed() throws Exception {
when(preferencesManager.getValue(eq(LINK_WITH_EDITOR))).thenReturn(null);
action.actionPerformed(new ActionEvent(new Presentation(), null, null));
verify(preferencesManager).setValue("linkWithEditor", Boolean.toString(true));
verify(eventBus).fireEvent((Event<?>) anyObject());
}