下面列出了怎么用org.eclipse.ui.forms.IMessageManager的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* This operation changes the dirty state of the FormEditor.
*
* @param value
*/
public void setDirty(boolean value) {
// Set the dirty value and fire a property change
dirty = value;
firePropertyChange(PROP_DIRTY);
// Push a message to the message manager
if (getHeaderForm() != null) {
final IMessageManager messageManager = getHeaderForm()
.getMessageManager();
if (dirty) {
messageManager.addMessage("statusUpdate",
"There are unsaved changes on the form.", null,
IMessageProvider.WARNING);
} else {
messageManager.removeMessage("statusUpdate");
// messageManager.addMessage("statusUpdate", "Form Saved", null,
// IMessageProvider.INFORMATION);
}
}
}
/**
* This operation posts a status message to the ICEFormEditor should be
* displayed to the user or system viewing the widget. It is a simple
* string.
*
* @param statusMessage
* The status message.
*/
public void updateStatus(String statusMessage) {
// Local Declarations
final String message = statusMessage;
// Sync with the display
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
// Post the message to the update manager
if (getHeaderForm() != null) {
final IMessageManager messageManager = getHeaderForm()
.getMessageManager();
messageManager.addMessage("statusUpdate", message, null,
IMessageProvider.INFORMATION);
}
}
});
}
public void initialize(final IViewerController constraintController, final IMessageManager messageManager,
final EMFDataBindingContext emfDataBindingContext) {
this.messageManager = messageManager;
this.constraintController = constraintController;
this.emfDataBindingContext = emfDataBindingContext;
final ProcessItemProviderAdapterFactory adapterFactory = new ProcessItemProviderAdapterFactory();
propertySourceProvider = new AdapterFactoryContentProvider(adapterFactory);
adapterFactoryLabelProvider = new AdapterFactoryLabelProvider(adapterFactory);
getTable().setHeaderVisible(true);
getTable().setLinesVisible(true);
setContentProvider(new ObservableListContentProvider());
final CellNavigationStrategy cellNavigationStrategy = new AddRowOnEnterCellNavigationStrategy(this, constraintController);
final TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(this, new FocusCellOwnerDrawHighlighter(
this), cellNavigationStrategy);
TableViewerEditor.create(this, focusCellManager, new CharriageColumnViewerEditorActivationStrategy(this), ColumnViewerEditor.TABBING_HORIZONTAL |
ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR |
ColumnViewerEditor.TABBING_VERTICAL |
ColumnViewerEditor.KEYBOARD_ACTIVATION);
ColumnViewerToolTipSupport.enableFor(this);
createColumns();
configureTableLayout();
}
public void validateId(final String sectionId, final Control widget, List<String> values, String errorMessagePrefix, String elementType)
{
String message;
IMessageManager mm = getManagedForm().getMessageManager();
for (int i = 0; i < values.size(); i++)
{
String value = values.get(i);
if (!FormHelper.isIdentifier(value))
{
if (value.trim().equals(""))
{
message = elementType + " has been omitted.";
} else
{
message = elementType
+ " "
+ value
+ " may not be used, since it is not a valid identifier."
+ "\nAn identifier is a non-empty sequence of letters, digits and '_' with at least one letter.";
}
mm.addMessage(errorMessagePrefix + i, message, value.toString(), IMessageProvider.ERROR, widget);
setComplete(false);
expandSection(sectionId);
}
}
}
public void addGlobalTLCErrorMessage(String key, String message)
{
IMessageManager mm = getManagedForm().getMessageManager();
mm.addMessage(key, message, null, IMessageProvider.WARNING);
/*globalTLCErrorHyperLink.setText(TLC_ERROR_STRING);
globalTLCErrorHyperLink.setToolTipText(tooltipText);
globalTLCErrorHyperLink.setForeground(TLCUIActivator.getColor(SWT.COLOR_DARK_YELLOW));
globalTLCErrorHyperLink.addHyperlinkListener(globalTLCErrorHyperLinkListener);*/
}
/**
* This operation sets the message manager that should be used by this
* composite and its children to post messages.
*
* @param manager
* The message manager.
*/
public void setMessageManager(IMessageManager manager) {
// Set the class reference
messageManager = manager;
// Set the message manager if it is available
if (messageManager != null) {
for (IEntryComposite composite : entryMap.values()) {
composite.setMessageManager(messageManager);
}
}
return;
}
@Override
public void setMessageManager(IMessageManager manager) {
// Set the messageManager
messageManager = manager;
return;
}
public CustomTextEMFObservableValueEditingSupport(final ColumnViewer viewer, final EStructuralFeature featureToEdit,
final IMessageManager messageManager, final DataBindingContext dbc) {
super(viewer, dbc);
this.dbc = dbc;
this.messageManager = messageManager;
this.featureToEdit = featureToEdit;
}
public InputNameObservableEditingSupport(final ColumnViewer viewer,
final IMessageManager messageManager,
final DataBindingContext dbc,
final IRefactorOperationFactory contractInputRefactorOperationFactory,
final IProgressService progressService) {
super(viewer, ProcessPackage.Literals.CONTRACT_INPUT__NAME, messageManager, dbc);
this.progressService = progressService;
this.contractInputRefactorOperationFactory = contractInputRefactorOperationFactory;
}
public void initialize(final ContractInputController inputController, final IMessageManager messageManager,
final EMFDataBindingContext emfDataBindingContext) {
this.messageManager = messageManager;
this.inputController = inputController;
this.emfDataBindingContext = emfDataBindingContext;
final ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(
ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
propertySourceProvider = new ContractInputTypePropertyDescriptor(adapterFactory);
adapterFactoryLabelProvider = new AdapterFactoryLabelProvider(adapterFactory);
getTree().setHeaderVisible(true);
getTree().setLinesVisible(true);
addFilter(new ComplexTypeChildrenViewerFilter());
final ObservableListTreeContentProvider contentProvider = new ObservableListTreeContentProvider(
new ContractInputObservableFactory(),
new ContractInputTreeStructureAdvisor());
setContentProvider(contentProvider);
final CellNavigationStrategy cellNavigationStrategy = new AddRowOnEnterCellNavigationStrategy(this, inputController);
final TreeViewerFocusCellManager focusCellManager = new TreeViewerFocusCellManager(this,
new FocusCellOwnerDrawHighlighter(
this),
cellNavigationStrategy);
TreeViewerEditor.create(this, focusCellManager, new CharriageColumnViewerEditorActivationStrategy(this),
ColumnViewerEditor.TABBING_HORIZONTAL |
ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR |
ColumnViewerEditor.TABBING_VERTICAL |
ColumnViewerEditor.KEYBOARD_ACTIVATION);
ColumnViewerToolTipSupport.enableFor(this);
createColumns();
configureTableLayout();
}
public void validateUsage(final String sectionId, final Control widget, List<String> values, String errorMessagePrefix, String elementType,
String listSourceDescription, boolean addToContext)
{
IMessageManager mm = getManagedForm().getMessageManager();
SemanticHelper helper = getLookupHelper();
String message;
for (int i = 0; i < values.size(); i++)
{
String value = values.get(i);
Object usageHint = helper.getUsedHint(value);
if (usageHint != null)
{
message = elementType + " " + value + " may not be used, since it is ";
if (usageHint instanceof SymbolNode)
{
message += "";
SymbolNode node = (SymbolNode) usageHint;
Location location = node.getLocation();
if (location.source().equals(SemanticHelper.TLA_BUILTIN))
{
message += "a built-in TLA+ definition.";
} else
{
message += "an identifier already defined at " + location.toString() + ".";
}
} else if (usageHint instanceof String)
{
if (SemanticHelper.KEYWORD.equals(usageHint))
{
message += "a TLA+ keyword.";
} else
{
message += "already used in " + usageHint;
}
} else
{
message = "Error during validation. This is a bug";
}
mm.addMessage(errorMessagePrefix + i, message, value.toString(), IMessageProvider.ERROR, widget);
setComplete(false);
expandSection(sectionId);
} else
{
// just adding the name
if (addToContext)
{
helper.addName(value, this, listSourceDescription);
}
}
}
}
protected IMessageManager getMessageManager() {
if (form != null) {
return form.getMessageManager();
}
return null;
}
public ErrorMessageObservableEditingSupport(final ColumnViewer viewer,
final IMessageManager messageManager,
final DataBindingContext dbc) {
super(viewer, ProcessPackage.Literals.CONTRACT_CONSTRAINT__ERROR_MESSAGE, messageManager, dbc);
}
public DescriptionObservableEditingSupport(final ColumnViewer viewer,
final IMessageManager messageManager,
final DataBindingContext dbc) {
super(viewer, ProcessPackage.Literals.CONTRACT_CONSTRAINT__DESCRIPTION, messageManager, dbc);
}
public ConstraintNameObservableEditingSupport(final ColumnViewer viewer,
final IMessageManager messageManager,
final DataBindingContext dbc) {
super(viewer, ProcessPackage.Literals.CONTRACT_CONSTRAINT__NAME, messageManager, dbc);
}
public DescriptionObservableEditingSupport(final ColumnViewer viewer,
final IMessageManager messageManager,
final DataBindingContext dbc) {
super(viewer, ProcessPackage.Literals.CONTRACT_INPUT__DESCRIPTION, messageManager, dbc);
}
/**
* This operation sets the Message Manager that should be used by the
* EntryComposite to post messages about the Entry. If the Message Manager
* is not set, the EntryComposite will not attempt to post messages.
*
* @param manager
* The Message Manager that the EntryComposite should use.
*/
public void setMessageManager(IMessageManager manager);