下面列出了怎么用org.eclipse.ui.IWorkbenchPartConstants的API类实例代码及写法,或者点击链接到github查看源代码。
public void doSaveAs( )
{
getActivePageInstance( ).doSaveAs( );
setInput( getActivePageInstance( ).getEditorInput( ) );
// update site name
IReportProvider provider = getProvider( );
if ( provider != null )
{
setPartName( provider.getInputPath( getEditorInput( ) )
.lastSegment( ) );
firePropertyChange( IWorkbenchPartConstants.PROP_PART_NAME );
getProvider( ).getReportModuleHandle( getEditorInput( ) )
.setFileName( getProvider( ).getInputPath( getEditorInput( ) )
.toOSString( ) );
}
updateRelatedViews( );
fireDesignFileChangeEvent( );
}
/**
* This was the body of the <code>execute</code>, but was pulled out so it could be
* used in other places to open a module.
*
* @param moduleName
*/
public static void openModule(String moduleName) {
if (moduleName == null)
{
throw new RuntimeException("Module was null" );
}
Spec spec = Activator.getSpecManager().getSpecLoaded();
final IFile module = ResourceHelper.getLinkedFile(spec.getProject(), ResourceHelper.getModuleFileName(moduleName));
if (module == null)
{
throw new RuntimeException("Module " + moduleName + " could not be found" );
}
// open the editor
IEditorPart part = UIHelper.openEditor(OpenSpecHandler.TLA_EDITOR, new FileEditorInput(module));
part.addPropertyListener(new IPropertyListener() {
public void propertyChanged(Object source, int propId)
{
if (IWorkbenchPartConstants.PROP_DIRTY == propId)
{
// here the listeners to editor changes go into
}
}
});
}
private void setAllInput( FileEditorInput input )
{
// This for a bug. When close editor, the resource listener fire to
// multi page editor, but all embedded pages disposed.
if ( pages == null )
{
return;
}
setInput( input );
if ( getEditorInput( ) != null )
{
setPartName( getEditorInput( ).getName( ) );
firePropertyChange( IWorkbenchPartConstants.PROP_PART_NAME );
firePropertyChange( IWorkbenchPartConstants.PROP_PART_NAME );
getProvider( ).getReportModuleHandle( getEditorInput( ) )
.setFileName( getProvider( ).getInputPath( getEditorInput( ) )
.toOSString( ) );
}
for ( Iterator it = pages.iterator( ); it.hasNext( ); )
{
Object page = it.next( );
if ( page instanceof IReportEditorPage )
{
( (IReportEditorPage) page ).setInput( input );
}
}
updateRelatedViews( );
}
public void propertyChanged( Object source, int propId )
{
if ( propId == IWorkbenchPartConstants.PROP_PART_NAME )
{
setPartName( instance.getPartName( ) );
}
firePropertyChange( propId );
}
private void handlePropertyChangedEvent( int propertyId ) {
if( propertyId == IWorkbenchPartConstants.PROP_INPUT ) {
updateContent();
}
}
@Override
public void run() {
IPath ignoreThrownExceptionsPath = PyExceptionBreakPointManager
.getInstance().ignoreCaughtExceptionsWhenThrownFrom
.getIgnoreThrownExceptionsPath();
File file = ignoreThrownExceptionsPath.toFile();
IEditorPart openFile = EditorUtils.openFile(file);
if (openFile instanceof ITextEditor) {
final ITextEditor textEditor = (ITextEditor) openFile;
IDocumentProvider documentProvider = textEditor.getDocumentProvider();
final IEditorInput input = openFile.getEditorInput();
if (documentProvider instanceof IStorageDocumentProvider) {
IStorageDocumentProvider storageDocumentProvider = (IStorageDocumentProvider) documentProvider;
// Make sure the file is seen as UTF-8.
storageDocumentProvider.setEncoding(input, "utf-8");
textEditor.doRevertToSaved();
}
if (textEditor instanceof ISaveablePart) {
IPropertyListener listener = new IPropertyListener() {
@Override
public void propertyChanged(Object source, int propId) {
if (propId == IWorkbenchPartConstants.PROP_DIRTY) {
if (source == textEditor) {
if (textEditor.getEditorInput() == input) {
if (!textEditor.isDirty()) {
PyExceptionBreakPointManager.getInstance().ignoreCaughtExceptionsWhenThrownFrom
.updateIgnoreThrownExceptions();
}
}
}
}
}
};
textEditor.addPropertyListener(listener);
}
}
// Code to provide a dialog to edit it (decided on opening the file instead).
// Collection<IgnoredExceptionInfo> ignoreThrownExceptionsForEdition = PyExceptionBreakPointManager.getInstance()
// .getIgnoreThrownExceptionsForEdition();
// HashMap<String, String> map = new HashMap<>();
// for (IgnoredExceptionInfo ignoredExceptionInfo : ignoreThrownExceptionsForEdition) {
// map.put(ignoredExceptionInfo.filename + ": " + ignoredExceptionInfo.line, ignoredExceptionInfo.contents);
// }
//
// EditIgnoredCaughtExceptionsDialog dialog = new EditIgnoredCaughtExceptionsDialog(EditorUtils.getShell(), map);
// int open = dialog.open();
// if (open == dialog.OK) {
// Map<String, String> result = dialog.getResult();
//
// } else {
// System.out.println("Cancel");
// }
}