下面列出了怎么用org.eclipse.ui.dialogs.PropertyPage的API类实例代码及写法,或者点击链接到github查看源代码。
public void updateMessage( )
{
PropertyPage propertyPage = getCurrentPropertyPage( );
if ( propertyPage != null )
{
String message = propertyPage.getMessage( );
int messageType = propertyPage.getMessageType( );
// if error message exists, it takes precedence over page's non-error message
if ( messageType < IMessageProvider.ERROR )
{
String errMessage = propertyPage.getErrorMessage();
if ( errMessage != null )
{
message = errMessage;
messageType = IMessageProvider.ERROR;
}
}
setMessage( message, messageType );
}
}
/**
* get current PropertyPage
*
* @return
*/
private PropertyPage getCurrentPropertyPage( )
{
if ( getCurrentNode( ) != null )
{
IPropertyPage ipropertyPage = getCurrentNode( ).getPage( );
if ( ipropertyPage instanceof PropertyPageWrapper )
return ( (PropertyPageWrapper) ipropertyPage ).getPropertyPage( );
}
return null;
}
public void updateButtons( )
{
if ( getOkButton( ) != null )
{
PropertyPage propertyPage = this.getCurrentPropertyPage( );
if ( propertyPage != null )
{
getOkButton( ).setEnabled( propertyPage.okToLeave( ) );
}
else if ( getCurrentNode( ).getPage( ) instanceof WizardPage )
{
getOkButton( ).setEnabled( ( (WizardPage) getCurrentNode( ).getPage( ) ).isPageComplete( ) );
}
}
}
public void updateMessage( )
{
PropertyPage propertyPage = getCurrentPropertyPage( );
if ( propertyPage != null )
setMessage( propertyPage.getMessage( ),
propertyPage.getMessageType( ) );
}
public void updateButtons( )
{
if ( getOkButton( ) != null )
{
PropertyPage propertyPage = getCurrentPropertyPage( );
if ( propertyPage != null )
getOkButton( ).setEnabled( propertyPage.isValid( ) );
}
}
/**
*
* @return
*/
private PropertyPage getCurrentPropertyPage( )
{
if ( getCurrentNode( ) == null )
return null;
IPropertyPage currentPage = getCurrentNode( ).getPage( );
if ( !( currentPage instanceof PropertyPageWrapper ) )
return null;
return ( (PropertyPageWrapper) currentPage ).getPropertyPage( );
}
@Override
public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager,
IStatusLineManager statusLineManager) {
super.makeContributions(menuManager, toolBarManager, statusLineManager);
// TODO: Figure out how to use open properties dialog action here correctly
// see http://wiki.eclipse.org/FAQ_How_do_I_open_a_Property_dialog%3F
IAction action = new Action() {
@Override
public void run() {
super.run();
ISelection sel = new StructuredSelection(new AnnotationTypeNode(editor, null));
PropertyPage page = new EditorAnnotationPropertyPage();
page.setElement(new AnnotationTypeNode(editor, null));
page.setTitle("Styles");
PreferenceManager mgr = new PreferenceManager();
IPreferenceNode node = new PreferenceNode("1", page);
mgr.addToRoot(node);
PropertyDialog dialog = new PropertyDialog(getSite().getShell(), mgr, sel);
dialog.create();
dialog.setMessage(page.getTitle());
dialog.open();
}
};
action.setImageDescriptor(CasEditorPlugin
.getTaeImageDescriptor(Images.MODEL_PROCESSOR_FOLDER));
toolBarManager.add(action);
}
public PropertyPageWrapper( PropertyPage propertyPage,
DataSetDesignSession m_designSession )
{
this.propertyPage = propertyPage;
this.dataSetSession = m_designSession;
}
public PropertyPageWrapper( PropertyPage propertyPage,
DataSourceDesignSession m_designSession )
{
this.propertyPage = propertyPage;
this.dataSourceSession = m_designSession;
}
public PropertyPage getPropertyPage( )
{
return propertyPage;
}