下面列出了怎么用org.eclipse.ui.menus.UIElement的API类实例代码及写法,或者点击链接到github查看源代码。
public void updateElement(UIElement element, Map parameters) {
String layout = (String) parameters.get("xliffEditor.layout");
if (XLIFFEditorImplWithNatTable.getCurrent().isHorizontalLayout()) {
ImageDescriptor horizontalImageDescriptor = Activator
.getImageDescriptor(layout == null ? ImageConstant.TOOL_LAYOUT_HORIZONTAL
: "images/view/horizontal.png");
element.setIcon(horizontalImageDescriptor);
element.setTooltip(Messages.getString("handler.ChangeEditorLayoutHandler.horizontalTooltip"));
} else {
ImageDescriptor verticalImageDescriptor = Activator
.getImageDescriptor(layout == null ? ImageConstant.TOOL_LAYOUT_VERTICAL
: "images/view/vertical.png");
element.setIcon(verticalImageDescriptor);
element.setTooltip(Messages.getString("handler.ChangeEditorLayoutHandler.verticalTooltip"));
}
}
public void updateElement(UIElement element, Map parameters) {
String layout = (String) parameters.get("xliffEditor.layout");
if (XLIFFEditorImplWithNatTable.getCurrent().isHorizontalLayout()) {
ImageDescriptor horizontalImageDescriptor = Activator
.getImageDescriptor(layout == null ? ImageConstant.TOOL_LAYOUT_HORIZONTAL
: "images/view/horizontal.png");
element.setIcon(horizontalImageDescriptor);
element.setTooltip(Messages.getString("handler.ChangeEditorLayoutHandler.horizontalTooltip"));
} else {
ImageDescriptor verticalImageDescriptor = Activator
.getImageDescriptor(layout == null ? ImageConstant.TOOL_LAYOUT_VERTICAL
: "images/view/vertical.png");
element.setIcon(verticalImageDescriptor);
element.setTooltip(Messages.getString("handler.ChangeEditorLayoutHandler.verticalTooltip"));
}
}
@Override
public void updateElement(UIElement element, Map parameters){
IPersistentObject po = ElexisEventDispatcher.getSelected(getTemplateClass());
if (po == null) {
element.setIcon(Images.IMG_LOCK_CLOSED.getImageDescriptor());
element.setChecked(false);
return;
}
if (LocalLockServiceHolder.get().isLockedLocal(po)) {
element.setIcon(Images.IMG_LOCK_OPEN.getImageDescriptor());
element.setChecked(true);
} else {
element.setIcon(Images.IMG_LOCK_CLOSED.getImageDescriptor());
element.setChecked(false);
}
}
@Override
public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters) {
IGoogleLoginService loginService =
element.getServiceLocator().getService(IGoogleLoginService.class);
boolean loggedIn = loginService.hasAccounts();
element.setText(loggedIn ? Messages.getString("LOGIN_MENU_LOGGED_IN")
: Messages.getString("LOGIN_MENU_LOGGED_OUT"));
}
@VisibleForTesting
void updateElement(
UIElement element,
@SuppressWarnings("rawtypes") Map parameters,
GcpStatusMonitoringService service) {
GcpStatus status = service.getCurrentStatus();
element.setText("Status: " + status.summary);
switch (status.severity) {
case OK:
element.setIcon(IMG_OK);
element.setTooltip(status.summary);
break;
case LOW:
element.setIcon(IMG_LOW);
element.setTooltip(summarizeIncidents(status.active));
break;
case MEDIUM:
element.setIcon(IMG_MEDIUM);
element.setTooltip(summarizeIncidents(status.active));
break;
case HIGH:
element.setIcon(IMG_HIGH);
element.setTooltip(summarizeIncidents(status.active));
break;
case ERROR:
default:
element.setIcon(IMG_ERROR);
element.setTooltip(status.summary); // show error text
break;
}
}
public void updateElement(UIElement element, Map parameters)
{
String parameter = (String) parameters.get(PARAM_PERSPECTIVE_ID);
if (parameter != null)
{
if (UIHelper.getActivePerspectiveId().equals(parameter))
{
element.setChecked(true);
} else
{
element.setChecked(false);
}
}
}
@Override
public void updateElement(final UIElement element, final Map parameters) {
element.setTooltip("Runs or pauses the current experiment (" + GamaKeyBindings.PLAY_STRING + ")");
if (GAMA.isPaused())
element.setText("Run Experiment (" + GamaKeyBindings.PLAY_STRING + ")");
else
element.setText("Pause Experiment (" + GamaKeyBindings.PLAY_STRING + ")");
}
@SuppressWarnings("rawtypes")
public void updateElement(UIElement element, Map parameters) {
IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();
boolean oldValue = preferenceStore.getBoolean(TsPreferencesConstant.TS_statusBar_status);
element.setIcon(oldValue ? Activator.getImageDescriptor("icons/enabled_co.png") : Activator
.getImageDescriptor("icons/disabled_co.png"));
}
@SuppressWarnings("rawtypes")
public void updateElement(final UIElement element, Map parameters) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
final IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (activeWorkbenchWindow instanceof WorkbenchWindow) {
WorkbenchWindow window = (WorkbenchWindow) activeWorkbenchWindow;
boolean coolbarVisible = window.getCoolBarVisible();
element.setIcon(coolbarVisible ? Activator.getImageDescriptor("icons/enabled_co.png") : Activator
.getImageDescriptor("icons/disabled_co.png"));
}
}
});
}
@SuppressWarnings("rawtypes")
public void updateElement(final UIElement element, Map parameters) {
if (parameters.get("ViewId") == null) {
return;
}
final String viewId = (String) parameters.get("ViewId");
Display.getDefault().asyncExec(new Runnable() {
public void run() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
IWorkbenchPage workbenchPage = window.getActivePage();
if (workbenchPage == null) {
return;
}
IViewPart view = workbenchPage.findView(viewId);
if (view == null) {
element.setIcon(Activator.getImageDescriptor("icons/disabled_co.png"));
} else {
element.setIcon(Activator.getImageDescriptor("icons/enabled_co.png"));
}
}
});
}
@SuppressWarnings("rawtypes")
public void updateElement(UIElement element, Map parameters) {
IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();
boolean oldValue = preferenceStore.getBoolean(TsPreferencesConstant.TS_statusBar_status);
element.setIcon(oldValue ? Activator.getImageDescriptor("icons/enabled_co.png") : Activator
.getImageDescriptor("icons/disabled_co.png"));
}
@SuppressWarnings("rawtypes")
public void updateElement(final UIElement element, Map parameters) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
final IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (activeWorkbenchWindow instanceof WorkbenchWindow) {
WorkbenchWindow window = (WorkbenchWindow) activeWorkbenchWindow;
boolean coolbarVisible = window.getCoolBarVisible();
element.setIcon(coolbarVisible ? Activator.getImageDescriptor("icons/enabled_co.png") : Activator
.getImageDescriptor("icons/disabled_co.png"));
}
}
});
}
@SuppressWarnings("rawtypes")
public void updateElement(final UIElement element, Map parameters) {
if (parameters.get("ViewId") == null) {
return;
}
final String viewId = (String) parameters.get("ViewId");
Display.getDefault().asyncExec(new Runnable() {
public void run() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
IWorkbenchPage workbenchPage = window.getActivePage();
if (workbenchPage == null) {
return;
}
IViewPart view = workbenchPage.findView(viewId);
if (view == null) {
element.setIcon(Activator.getImageDescriptor("icons/disabled_co.png"));
} else {
element.setIcon(Activator.getImageDescriptor("icons/enabled_co.png"));
}
}
});
}
@Override
public void updateElement(UIElement element, Map parameters){
if (localIcon == null || remoteIcon == null || standaloneIcon == null) {
prepareIcons();
}
ILocalLockService.Status status = LocalLockServiceHolder.get().getStatus();
if (status == Status.STANDALONE) {
element.setIcon(standaloneIcon);
} else if (status == Status.LOCAL) {
element.setIcon(localIcon);
} else if (status == Status.REMOTE) {
element.setIcon(remoteIcon);
}
}
@Override
public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters){
boolean isSuspended =
ConfigServiceHolder.get().getLocal(Preferences.INVENTORY_MACHINE_SUSPEND_OUTLAY,
Preferences.INVENTORY_MACHINE_SUSPEND_OUTLAY_DEFAULT);
if (isSuspended) {
element.setChecked(false);
element.setIcon(Images.IMG_DRAWER.getImageDescriptor());
} else {
element.setChecked(true);
element.setIcon(Images.IMG_DRAWER_ARROW.getImageDescriptor());
}
}
@Override
public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters) {
GcpStatusMonitoringService service = element.getServiceLocator().getService(GcpStatusMonitoringService.class);
updateElement(element, parameters, service);
}
/**
* {@inheritDoc}
*/
@Override
public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters) {
boolean on = PreferenceKeys.PKEY_HIGHLIGHT_OCCURENCES.getStoredBoolean();
element.setChecked(on);
}
@Override
public void updateElement(final UIElement element, final Map parameters) {
element.setTooltip("Reloads the current experiment (" + GamaKeyBindings.RELOAD_STRING + ")");
element.setText("Reload Experiment (" + GamaKeyBindings.RELOAD_STRING + ")");
}
@Override
public void updateElement(final UIElement element, final Map parameters) {
element.setChecked(GamaPreferences.Runtime.CORE_SHOW_ERRORS.getValue());
}
@Override
public void updateElement(final UIElement element, final Map parameters) {
element.setChecked(GamaPreferences.Runtime.CORE_REVEAL_AND_STOP.getValue());
}
@Override
public void updateElement(final UIElement element, final Map parameters) {
element.setChecked(GamaPreferences.Runtime.CORE_WARNINGS.getValue());
}
@Override
public void updateElement(final UIElement element, final Map parameters) {
element.setTooltip("Runs the experiment one step at a time (" + GamaKeyBindings.STEP_STRING + ")");
element.setText("Step Experiment (" + GamaKeyBindings.STEP_STRING + ")");
}
@Override
public void updateElement(final UIElement element, final Map parameters) {
element.setTooltip("Closes the current experiment (" + GamaKeyBindings.QUIT_STRING + ")");
element.setText("Close Experiment (" + GamaKeyBindings.QUIT_STRING + ")");
}
public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters) {
element.setChecked(isSelected);
}
public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters) {
element.setChecked(isSelected);
}
public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters) {
element.setChecked(isSelected);
}
@Override
public void updateElement(UIElement element, Map parameters){
boolean bFlat = CoreHub.userCfg.get(DocumentsView.SETTING_FLAT_VIEW, false);
element.setChecked(bFlat);
}
@Override
public void updateElement(UIElement element, @SuppressWarnings("rawtypes")
Map parameters){
element.setIcon(Images.IMG_FILTER.getImageDescriptor());
}
public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters) {
}