protected void handleDefaultSelected(TypeNameMatch[] selection) { if (selection.length == 0) return; okPressed(); }
public void setFilter(String filter) { setFilter(filter, FULL_SELECTION); }
public TypeSelectionDialog2(Shell parent, boolean multi, IRunnableContext context, IJavaSearchScope scope, int elementKinds, TypeSelectionExtension extension) { super(parent); setShellStyle(getShellStyle() | SWT.RESIZE); fMultipleSelection= multi; fRunnableContext= context; fScope= scope; fElementKind= elementKinds; fSelectionMode= NONE; fExtension= extension; if (fExtension != null) { fValidator= fExtension.getSelectionValidator(); } }
/** * Opens a selection dialog that allows to select a super class. * * @return returns the selected type or <code>null</code> if the dialog has been canceled. * The caller typically sets the result to the super class input field. * <p> * Clients can override this method if they want to offer a different dialog. * </p> * * @since 3.2 */ protected IType chooseSuperClass() { IPackageFragmentRoot root= getPackageFragmentRoot(); if (root == null) { return null; } IJavaElement[] elements= new IJavaElement[] { root.getJavaProject() }; IJavaSearchScope scope= SearchEngine.createJavaSearchScope(elements); TypeSelectionDialog2 dialog= new TypeSelectionDialog2(getShell(), false, getWizard().getContainer(), scope, IJavaSearchConstants.CLASS); dialog.setTitle(NewWizardMessages.NewTypeWizardPage_SuperClassDialog_title); dialog.setMessage(NewWizardMessages.NewTypeWizardPage_SuperClassDialog_message); dialog.setFilter(getSuperClass()); if (dialog.open() == Window.OK) { return (IType) dialog.getFirstResult(); } return null; }
protected void computeResult() { TypeNameMatch[] selected= fContent.getSelection(); if (selected == null || selected.length == 0) { setResult(null); return; String containerName= JavaElementLabels.getElementLabel(root, JavaElementLabels.ROOT_QUALIFIED); String message= Messages.format(JavaUIMessages.TypeSelectionDialog_dialogMessage, new String[] { typeInfo.getFullyQualifiedName(), containerName }); MessageDialog.openError(getShell(), title, message); history.remove(typeInfo); setResult(null); } else { history.accessed(typeInfo); setResult(result);
@Override public boolean close() { boolean result; try { if (getReturnCode() == OK) { OpenTypeHistory.getInstance().save(); } } finally { result= super.close(); } return result; }
@Override public void create() { super.create(); fContent.populate(fSelectionMode); getOkButton().setEnabled(fContent.getSelection().length > 0); }
protected Control createDialogArea(Composite parent) { Composite area= (Composite)super.createDialogArea(parent); fContent= new TypeSelectionComponent(area, SWT.NONE, getMessage(), fMultipleSelection, fScope, fElementKind, fInitialFilter, new TitleLabel(), fExtension); GridData gd= new GridData(GridData.FILL_BOTH); fContent.setLayoutData(gd); fContent.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { handleDefaultSelected(fContent.getSelection()); } public void widgetSelected(SelectionEvent e) { handleWidgetSelected(fContent.getSelection()); } }); return area; }
public int open() { try { ensureConsistency(); } catch (InvocationTargetException e) { ExceptionHandler.handle(e, JavaUIMessages.TypeSelectionDialog_error3Title, JavaUIMessages.TypeSelectionDialog_error3Message); return CANCEL; } catch (InterruptedException e) { // cancelled by user return CANCEL; } if (fInitialFilter == null) { IWorkbenchWindow window= JavaPlugin.getActiveWorkbenchWindow(); if (window != null) { ISelection selection= window.getSelectionService().getSelection(); if (selection instanceof ITextSelection) { String text= ((ITextSelection)selection).getText(); if (text != null) { text= text.trim(); if (text.length() > 0 && JavaConventions.validateJavaTypeName(text, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3).isOK()) { fInitialFilter= text; fSelectionMode= FULL_SELECTION; } } } } } return super.open(); }
TypeSelectionDialog2 dialog= new TypeSelectionDialog2(getShell(), false, getWizard().getContainer(), scope, IJavaSearchConstants.TYPE); dialog.setTitle(NewWizardMessages.NewTypeWizardPage_ChooseEnclosingTypeDialog_title); dialog.setMessage(NewWizardMessages.NewTypeWizardPage_ChooseEnclosingTypeDialog_description); dialog.setFilter(Signature.getSimpleName(getEnclosingTypeText())); if (dialog.open() == Window.OK) { return (IType) dialog.getFirstResult();
public TypeSelectionDialog2(Shell parent, boolean multi, IRunnableContext context, IJavaSearchScope scope, int elementKinds, TypeSelectionExtension extension) { super(parent); setShellStyle(getShellStyle() | SWT.RESIZE); fMultipleSelection= multi; fRunnableContext= context; fScope= scope; fElementKind= elementKinds; fSelectionMode= NONE; fExtension= extension; if (fExtension != null) { fValidator= fExtension.getSelectionValidator(); } }
TypeNameMatch[] selected= fContent.getSelection(); if (selected == null || selected.length == 0) { setResult(null); return; String containerName= JavaElementLabels.getElementLabel(root, JavaElementLabels.ROOT_QUALIFIED); String message= Messages.format(JavaUIMessages.TypeSelectionDialog_dialogMessage, new String[] { typeInfo.getFullyQualifiedName(), containerName }); MessageDialog.openError(getShell(), title, message); history.remove(typeInfo); setResult(null); } else { history.accessed(typeInfo); setResult(result);
public boolean close() { boolean result; try { if (getReturnCode() == OK) { OpenTypeHistory.getInstance().save(); } } finally { result= super.close(); } return result; }
public void create() { super.create(); fContent.populate(fSelectionMode); getOkButton().setEnabled(fContent.getSelection().length > 0); }
@Override protected Control createDialogArea(Composite parent) { Composite area= (Composite)super.createDialogArea(parent); fContent= new TypeSelectionComponent(area, SWT.NONE, getMessage(), fMultipleSelection, fScope, fElementKind, fInitialFilter, new TitleLabel(), fExtension); GridData gd= new GridData(GridData.FILL_BOTH); fContent.setLayoutData(gd); fContent.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { handleDefaultSelected(fContent.getSelection()); } @Override public void widgetSelected(SelectionEvent e) { handleWidgetSelected(fContent.getSelection()); } }); return area; }
@Override public int open() { try { ensureConsistency(); } catch (InvocationTargetException e) { ExceptionHandler.handle(e, JavaUIMessages.TypeSelectionDialog_error3Title, JavaUIMessages.TypeSelectionDialog_error3Message); return CANCEL; } catch (InterruptedException e) { // cancelled by user return CANCEL; } if (fInitialFilter == null) { IWorkbenchWindow window= JavaPlugin.getActiveWorkbenchWindow(); if (window != null) { ISelection selection= window.getSelectionService().getSelection(); if (selection instanceof ITextSelection) { String text= ((ITextSelection)selection).getText(); if (text != null) { text= text.trim(); if (text.length() > 0 && JavaConventions.validateJavaTypeName(text, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3).isOK()) { fInitialFilter= text; fSelectionMode= FULL_SELECTION; } } } } } return super.open(); }
public TypeSelectionDialog2(Shell parent, boolean multi, IRunnableContext context, IJavaSearchScope scope, int elementKinds, TypeSelectionExtension extension) { super(parent); setShellStyle(getShellStyle() | SWT.RESIZE); fMultipleSelection= multi; fRunnableContext= context; fScope= scope; fElementKind= elementKinds; fSelectionMode= NONE; fExtension= extension; if (fExtension != null) { fValidator= fExtension.getSelectionValidator(); } }
TypeNameMatch[] selected= fContent.getSelection(); if (selected == null || selected.length == 0) { setResult(null); return; String containerName= JavaElementLabels.getElementLabel(root, JavaElementLabels.ROOT_QUALIFIED); String message= Messages.format(JavaUIMessages.TypeSelectionDialog_dialogMessage, new String[] { typeInfo.getFullyQualifiedName(), containerName }); MessageDialog.openError(getShell(), title, message); history.remove(typeInfo); setResult(null); } else { history.accessed(typeInfo); setResult(result);
protected void handleDefaultSelected(TypeNameMatch[] selection) { if (selection.length == 0) return; okPressed(); }