/** * {@inheritDoc} */ @Override public final boolean invokeTool() throws IllegalStateException { if ( this.toolFutureTask != null ) { throw new IllegalStateException( "Tool is already running!" ); } boolean settingsValid = validateToolSettings(); if ( settingsValid ) { this.toolTask = this.tool.createToolTask( this.context, this.toolProgressListener, this.annotationListener ); prepareToolTask( this.toolTask ); this.toolFutureTask = this.taskExecutionService.execute( this.toolTask ); } return settingsValid; }
/** * {@inheritDoc} */ @Override public final void showDialog() { this.serviceReg = this.bundleContext.registerService( TaskStatusListener.class.getName(), this, null ); this.taskExecutionService.open(); this.annotationListener.open(); this.toolProgressListener.open(); onBeforeShowDialog(); setVisible( true ); }
/** * {@inheritDoc} */ @Override public final void close() { this.taskExecutionService.close(); this.annotationListener.close(); this.toolProgressListener.close(); try { this.serviceReg.unregister(); this.serviceReg = null; } catch ( IllegalStateException exception ) { // Ignore; we're closing anyway... } onBeforeCloseDialog(); setVisible( false ); dispose(); }
/** * Creates a new {@link BaseToolDialog} instance that is document modal. * * @param aOwner * the owning window of this dialog; * @param aTitle * the title of this dialog; * @param aContext * the tool context to use in this dialog. */ protected BaseToolDialog( final Window aOwner, final ToolContext aContext, final BundleContext aBundleContext, final Tool<RESULT_TYPE> aTool ) { super( aTool.getName() ); this.context = aContext; this.bundleContext = aBundleContext; this.tool = aTool; setModalExclusionType( ModalExclusionType.NO_EXCLUDE ); this.taskExecutionService = new TaskExecutionServiceTracker( aBundleContext ); this.annotationListener = new AnnotationListenerServiceTracker( aBundleContext ); this.toolProgressListener = new ToolProgressListenerServiceTracker( aBundleContext ); }