X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/wizards/NewElementWizard.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/wizards/NewElementWizard.java index 65bc255..3f95c8c 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/wizards/NewElementWizard.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/wizards/NewElementWizard.java @@ -30,27 +30,28 @@ import org.eclipse.ui.INewWizard; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; +import org.eclipse.ui.ide.IDE; import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard; - public abstract class NewElementWizard extends Wizard implements INewWizard { private IWorkbench fWorkbench; + private IStructuredSelection fSelection; public NewElementWizard() { setNeedsProgressMonitor(true); } - + protected void openResource(final IFile resource) { - final IWorkbenchPage activePage= PHPeclipsePlugin.getActivePage(); + final IWorkbenchPage activePage = PHPeclipsePlugin.getActivePage(); if (activePage != null) { - final Display display= getShell().getDisplay(); + final Display display = getShell().getDisplay(); if (display != null) { display.asyncExec(new Runnable() { public void run() { try { - activePage.openEditor(resource); + IDE.openEditor(activePage, resource, true); } catch (PartInitException e) { PHPeclipsePlugin.log(e); } @@ -59,26 +60,31 @@ public abstract class NewElementWizard extends Wizard implements INewWizard { } } } - + /** - * Subclasses should override to perform the actions of the wizard. - * This method is run in the wizard container's context as a workspace runnable. + * Subclasses should override to perform the actions of the wizard. This + * method is run in the wizard container's context as a workspace runnable. */ - protected void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException { + protected void finishPage(IProgressMonitor monitor) + throws InterruptedException, CoreException { } - - protected void handleFinishException(Shell shell, InvocationTargetException e) { - String title= NewWizardMessages.getString("NewElementWizard.op_error.title"); //$NON-NLS-1$ - String message= NewWizardMessages.getString("NewElementWizard.op_error.message"); //$NON-NLS-1$ + + protected void handleFinishException(Shell shell, + InvocationTargetException e) { + String title = NewWizardMessages + .getString("NewElementWizard.op_error.title"); //$NON-NLS-1$ + String message = NewWizardMessages + .getString("NewElementWizard.op_error.message"); //$NON-NLS-1$ ExceptionHandler.handle(e, shell, title, message); } - + /* * @see Wizard#performFinish - */ + */ public boolean performFinish() { - IWorkspaceRunnable op= new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException { + IWorkspaceRunnable op = new IWorkspaceRunnable() { + public void run(IProgressMonitor monitor) throws CoreException, + OperationCanceledException { try { finishPage(monitor); } catch (InterruptedException e) { @@ -91,34 +97,46 @@ public abstract class NewElementWizard extends Wizard implements INewWizard { } catch (InvocationTargetException e) { handleFinishException(getShell(), e); return false; - } catch (InterruptedException e) { + } catch (InterruptedException e) { return false; } return true; } - -// protected void warnAboutTypeCommentDeprecation() { -// String key= IUIConstants.DIALOGSTORE_TYPECOMMENT_DEPRECATED; -// if (OptionalMessageDialog.isDialogEnabled(key)) { -// Templates templates= Templates.getInstance(); -// boolean isOldWorkspace= templates.getTemplates("filecomment").length > 0 && templates.getTemplates("typecomment").length > 0; //$NON-NLS-1$ //$NON-NLS-2$ -// if (!isOldWorkspace) { -// OptionalMessageDialog.setDialogEnabled(key, false); -// } -// String title= NewWizardMessages.getString("NewElementWizard.typecomment.deprecated.title"); //$NON-NLS-1$ -// String message= NewWizardMessages.getString("NewElementWizard.typecomment.deprecated.message"); //$NON-NLS-1$ -// OptionalMessageDialog.open(key, getShell(), title, OptionalMessageDialog.getDefaultImage(), message, OptionalMessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0); -// } -// } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection) + + // protected void warnAboutTypeCommentDeprecation() { + // String key= IUIConstants.DIALOGSTORE_TYPECOMMENT_DEPRECATED; + // if (OptionalMessageDialog.isDialogEnabled(key)) { + // Templates templates= Templates.getInstance(); + // boolean isOldWorkspace= templates.getTemplates("filecomment").length > 0 + // && templates.getTemplates("typecomment").length > 0; + // //$NON-NLS-1$ //$NON-NLS-2$ + // if (!isOldWorkspace) { + // OptionalMessageDialog.setDialogEnabled(key, false); + // } + // String title= + // NewWizardMessages.getString("NewElementWizard.typecomment.deprecated.title"); + // //$NON-NLS-1$ + // String message= + // NewWizardMessages.getString("NewElementWizard.typecomment.deprecated.message"); + // //$NON-NLS-1$ + // OptionalMessageDialog.open(key, getShell(), title, + // OptionalMessageDialog.getDefaultImage(), message, + // OptionalMessageDialog.INFORMATION, new String[] { + // IDialogConstants.OK_LABEL }, 0); + // } + // } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, + * org.eclipse.jface.viewers.IStructuredSelection) */ public void init(IWorkbench workbench, IStructuredSelection currentSelection) { - fWorkbench= workbench; - fSelection= currentSelection; + fWorkbench = workbench; + fSelection = currentSelection; } - + public IStructuredSelection getSelection() { return fSelection; } @@ -128,7 +146,8 @@ public abstract class NewElementWizard extends Wizard implements INewWizard { } protected void selectAndReveal(IResource newResource) { - BasicNewResourceWizard.selectAndReveal(newResource, fWorkbench.getActiveWorkbenchWindow()); + BasicNewResourceWizard.selectAndReveal(newResource, fWorkbench + .getActiveWorkbenchWindow()); } }