org.eclipse.jdt.internal.ui.JavaUIMessages Java Examples

The following examples show how to use org.eclipse.jdt.internal.ui.JavaUIMessages. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OverrideMethodDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected Control createLinkControl(Composite composite) {
	Link link= new Link(composite, SWT.WRAP);
	link.setText(JavaUIMessages.OverrideMethodDialog_link_message);
	link.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			openCodeTempatePage(CodeTemplateContextType.OVERRIDECOMMENT_ID);
		}
	});
	link.setToolTipText(JavaUIMessages.OverrideMethodDialog_link_tooltip);

	GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
	gridData.widthHint= convertWidthInCharsToPixels(40); // only expand further if anyone else requires it
	link.setLayoutData(gridData);
	return link;
}
 
Example #2
Source File: OpenTypeHierarchyUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static TypeHierarchyViewPart openInViewPart(IWorkbenchWindow window, IJavaElement[] input) {
	IWorkbenchPage page= window.getActivePage();
	try {
		TypeHierarchyViewPart result= (TypeHierarchyViewPart) page.findView(JavaUI.ID_TYPE_HIERARCHY);
		if (result != null) {
			result.clearNeededRefresh(); // avoid refresh of old hierarchy on 'becomes visible'
		}
		result= (TypeHierarchyViewPart) page.showView(JavaUI.ID_TYPE_HIERARCHY);
		result.setInputElements(input);
		return result;
	} catch (CoreException e) {
		ExceptionHandler.handle(e, window.getShell(),
			JavaUIMessages.OpenTypeHierarchyUtil_error_open_view, e.getMessage());
	}
	return null;
}
 
Example #3
Source File: HistoryListAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void createMaxEntriesField() {
	fMaxEntriesField= new StringDialogField();
	fMaxEntriesField.setLabelText(fHistory.getMaxEntriesMessage());
	fMaxEntriesField.setDialogFieldListener(new IDialogFieldListener() {
		public void dialogFieldChanged(DialogField field) {
			String maxString= fMaxEntriesField.getText();
			boolean valid;
			try {
				fMaxEntries= Integer.parseInt(maxString);
				valid= fMaxEntries > 0 && fMaxEntries < MAX_MAX_ENTRIES;
			} catch (NumberFormatException e) {
				valid= false;
			}
			if (valid)
				updateStatus(StatusInfo.OK_STATUS);
			else
				updateStatus(new StatusInfo(IStatus.ERROR, Messages.format(JavaUIMessages.HistoryListAction_max_entries_constraint, Integer.toString(MAX_MAX_ENTRIES))));
		}
	});
	fMaxEntriesField.setText(Integer.toString(fHistory.getMaxEntries()));
}
 
Example #4
Source File: TypeSelectionComponent.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void createViewMenu(Composite parent) {
	fToolBar= new ToolBar(parent, SWT.FLAT);
	fToolItem= new ToolItem(fToolBar, SWT.PUSH, 0);

	GridData data= new GridData();
	data.horizontalAlignment= GridData.END;
	fToolBar.setLayoutData(data);

	fToolItem.setImage(JavaPluginImages.get(JavaPluginImages.IMG_ELCL_VIEW_MENU));
	fToolItem.setDisabledImage(JavaPluginImages.get(JavaPluginImages.IMG_DLCL_VIEW_MENU));
	fToolItem.setToolTipText(JavaUIMessages.TypeSelectionComponent_menu);
	fToolItem.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			showViewMenu();
		}
	});
	
	fMenuManager= new MenuManager();
	fillViewMenu(fMenuManager);

	// ICommandService commandService= (ICommandService)PlatformUI.getWorkbench().getAdapter(ICommandService.class);
	// IHandlerService handlerService= (IHandlerService)PlatformUI.getWorkbench().getAdapter(IHandlerService.class);
}
 
Example #5
Source File: JavaElementLabelComposer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Appends the label for a initializer. Considers the I_* flags.
 *
 * @param initializer the element to render
 * @param flags the rendering flags. Flags with names starting with 'I_' are considered.
 */
public void appendInitializerLabel(IInitializer initializer, long flags) {
	// qualification
	if (getFlag(flags, JavaElementLabels.I_FULLY_QUALIFIED)) {
		appendTypeLabel(initializer.getDeclaringType(), JavaElementLabels.T_FULLY_QUALIFIED | (flags & QUALIFIER_FLAGS));
		fBuffer.append('.');
	}
	fBuffer.append(JavaUIMessages.JavaElementLabels_initializer);

	// post qualification
	if (getFlag(flags, JavaElementLabels.I_POST_QUALIFIED)) {
		int offset= fBuffer.length();
		fBuffer.append(JavaElementLabels.CONCAT_STRING);
		appendTypeLabel(initializer.getDeclaringType(), JavaElementLabels.T_FULLY_QUALIFIED | (flags & QUALIFIER_FLAGS));
		if (getFlag(flags, JavaElementLabels.COLORIZE)) {
			fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE);
		}
	}
}
 
Example #6
Source File: JavaElementLabelComposer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void appendCategoryLabel(IMember member, long flags) throws JavaModelException {
	String[] categories= member.getCategories();
	if (categories.length > 0) {
		int offset= fBuffer.length();
		StringBuffer categoriesBuf= new StringBuffer();
		for (int i= 0; i < categories.length; i++) {
			if (i > 0)
				categoriesBuf.append(JavaElementLabels.CATEGORY_SEPARATOR_STRING);
			categoriesBuf.append(categories[i]);
		}
		fBuffer.append(JavaElementLabels.CONCAT_STRING);
		fBuffer.append(Messages.format(JavaUIMessages.JavaElementLabels_category, categoriesBuf.toString()));
		if (getFlag(flags, JavaElementLabels.COLORIZE)) {
			fBuffer.setStyle(offset, fBuffer.length() - offset, COUNTER_STYLE);
		}
	}
}
 
Example #7
Source File: JavaElementLinks.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected String getSimpleTypeName(IJavaElement enclosingElement, String typeSig) {
	String typeName= super.getSimpleTypeName(enclosingElement, typeSig);
	
	String title= ""; //$NON-NLS-1$
	String qualifiedName= Signature.toString(Signature.getTypeErasure(typeSig));
	int qualifierLength= qualifiedName.length() - typeName.length() - 1;
	if (qualifierLength > 0) {
		if (qualifiedName.endsWith(typeName)) {
			title= qualifiedName.substring(0, qualifierLength);
			title= Messages.format(JavaUIMessages.JavaElementLinks_title, title);
		} else {
			title= qualifiedName; // Not expected. Just show the whole qualifiedName.
		}
	}
	
	try {
		String uri= createURI(JAVADOC_SCHEME, enclosingElement, qualifiedName, null, null);
		return createHeaderLink(uri, typeName, title);
	} catch (URISyntaxException e) {
		JavaPlugin.log(e);
		return typeName;
	}
}
 
Example #8
Source File: FieldNameProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public ICompletionProposal[] computeCompletionProposals(IContentAssistSubjectControl contentAssistSubject, int documentOffset) {
	if (fFieldNameProposals.length == 0)
		return null;
	String input= contentAssistSubject.getDocument().get();

	ArrayList<JavaCompletionProposal> proposals= new ArrayList<JavaCompletionProposal>();
	String prefix= input.substring(0, documentOffset);
	ImageDescriptor imageDescriptor= JavaElementImageProvider.getFieldImageDescriptor(false, fRefactoring.getVisibility());
	Image image= fImageRegistry.get(imageDescriptor);
	for (int i= 0; i < fFieldNameProposals.length; i++) {
		String tempName= fFieldNameProposals[i];
		if (tempName.length() == 0 || ! tempName.startsWith(prefix))
			continue;
		JavaCompletionProposal proposal= new JavaCompletionProposal(tempName, 0, input.length(), image, tempName, 0);
		proposals.add(proposal);
	}
	fErrorMessage= proposals.size() > 0 ? null : JavaUIMessages.JavaEditor_codeassist_noCompletions;
	return proposals.toArray(new ICompletionProposal[proposals.size()]);
}
 
Example #9
Source File: VariableNamesProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public ICompletionProposal[] computeCompletionProposals(IContentAssistSubjectControl contentAssistSubject, int documentOffset) {
	if (fTempNameProposals.length == 0)
		return null;
	String input= contentAssistSubject.getDocument().get();

	ArrayList<JavaCompletionProposal> proposals= new ArrayList<JavaCompletionProposal>();
	String prefix= input.substring(0, documentOffset);
	Image image= fImageRegistry.get(fProposalImageDescriptor);
	for (int i= 0; i < fTempNameProposals.length; i++) {
		String tempName= fTempNameProposals[i];
		if (tempName.length() == 0 || ! tempName.startsWith(prefix))
			continue;
		JavaCompletionProposal proposal= new JavaCompletionProposal(tempName, 0, input.length(), image, tempName, 0);
		proposals.add(proposal);
	}
	fErrorMessage= proposals.size() > 0 ? null : JavaUIMessages.JavaEditor_codeassist_noCompletions;
	return proposals.toArray(new ICompletionProposal[proposals.size()]);
}
 
Example #10
Source File: GenerateToStringDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public GenerateToStringDialog(Shell shell, CompilationUnitEditor editor, IType type, IVariableBinding[] fields, IVariableBinding[] inheritedFields, IVariableBinding[] selectedFields,
		IMethodBinding[] methods, IMethodBinding[] inheritededMethods) throws JavaModelException {
	super(shell, new BindingLabelProvider(), new GenerateToStringContentProvider(fields, inheritedFields, methods, inheritededMethods), editor, type, false);
	setEmptyListMessage(JavaUIMessages.GenerateHashCodeEqualsDialog_no_entries);

	List<Object> selected= new ArrayList<Object>(Arrays.asList(selectedFields));
	if (selectedFields.length == fields.length && selectedFields.length > 0)
		selected.add(getContentProvider().getParent(selectedFields[0]));
	setInitialElementSelections(selected);

	setTitle(JavaUIMessages.GenerateToStringDialog_dialog_title);
	setMessage(JavaUIMessages.GenerateToStringDialog_select_fields_to_include);
	setValidator(new GenerateToStringValidator(fields.length + inheritedFields.length, methods.length + inheritededMethods.length));
	setSize(60, 18);
	setInput(new Object());

	fGenerationSettings= new ToStringGenerationSettings(getDialogSettings());
}
 
Example #11
Source File: GenerateToStringDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void browseForBuilderClass() {
	try {
		IJavaSearchScope scope= SearchEngine.createJavaSearchScope(new IJavaElement[] { getType().getJavaProject() });
		SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), PlatformUI.getWorkbench().getProgressService(), scope,
				IJavaElementSearchConstants.CONSIDER_CLASSES, false, "*ToString", fExtension); //$NON-NLS-1$
		dialog.setTitle(JavaUIMessages.GenerateToStringDialog_customBuilderConfig_classSelection_windowTitle);
		dialog.setMessage(JavaUIMessages.GenerateToStringDialog_customBuilderConfig_classSelection_message);
		dialog.open();
		if (dialog.getReturnCode() == OK) {
			IType type= (IType)dialog.getResult()[0];
			fBuilderClassName.setText(type.getFullyQualifiedParameterizedName());
			List<String> suggestions= fValidator.getAppendMethodSuggestions(type);
			if (!suggestions.contains(fAppendMethodName.getText()))
				fAppendMethodName.setText(suggestions.get(0));
			suggestions= fValidator.getResultMethodSuggestions(type);
			if (!suggestions.contains(fResultMethodName.getText()))
				fResultMethodName.setText(suggestions.get(0));
		}
	} catch (JavaModelException e) {
		JavaPlugin.log(e);
	}
}
 
Example #12
Source File: GenerateToStringDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public IStatus validate(Object[] selection) {
	if (getGenerationSettings().toStringStyle == GenerateToStringOperation.CUSTOM_BUILDER) {
		if (fValidator == null)
			fValidator= new CustomBuilderValidator(getType().getJavaProject());
		IStatus status= fValidator.revalidateAll(getGenerationSettings().getCustomBuilderSettings());
		if (!status.isOK())
			return new StatusInfo(IStatus.ERROR, JavaUIMessages.GenerateToStringDialog_selectioninfo_customBuilderConfigError);
	}

	int countFields= 0, countMethods= 0;
	for (int index= 0; index < selection.length; index++) {
		if (selection[index] instanceof IVariableBinding)
			countFields++;
		else if (selection[index] instanceof IMethodBinding)
			countMethods++;
	}

	return new StatusInfo(IStatus.INFO, Messages.format(JavaUIMessages.GenerateToStringDialog_selectioninfo_more, new String[] { String.valueOf(countFields), String.valueOf(fNumFields),
			String.valueOf(countMethods), String.valueOf(fNumMethods) }));
}
 
Example #13
Source File: ResourceTransferDragAdapter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void handleFinishedDropMove(DragSourceEvent event) {
	MultiStatus status= new MultiStatus(
		JavaPlugin.getPluginId(),
		IJavaStatusConstants.INTERNAL_ERROR,
		JavaUIMessages.ResourceTransferDragAdapter_cannot_delete_resource,
		null);
	List<IResource> resources= convertSelection();
	for (Iterator<IResource> iter= resources.iterator(); iter.hasNext();) {
		IResource resource= iter.next();
		try {
			resource.delete(true, null);
		} catch (CoreException e) {
			status.add(e.getStatus());
		}
	}
	int childrenCount= status.getChildren().length;
	if (childrenCount > 0) {
		Shell parent= SWTUtil.getShell(event.widget);
		ErrorDialog error= new ErrorDialog(parent,
				JavaUIMessages.ResourceTransferDragAdapter_moving_resource,
				childrenCount == 1 ? JavaUIMessages.ResourceTransferDragAdapter_cannot_delete_files_singular : Messages.format(
						JavaUIMessages.ResourceTransferDragAdapter_cannot_delete_files_plural, String.valueOf(childrenCount)), status, IStatus.ERROR);
		error.open();
	}
}
 
Example #14
Source File: FilteredTypesSelectionDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
	if (fgFirstTime) {
		// Join the initialize after load job.
		IJobManager manager= Job.getJobManager();
		manager.join(JavaUI.ID_PLUGIN, monitor);
	}
	OpenTypeHistory history= OpenTypeHistory.getInstance();
	if (fgFirstTime || history.isEmpty()) {
		if (history.needConsistencyCheck()) {
			monitor.beginTask(JavaUIMessages.TypeSelectionDialog_progress_consistency, 100);
			refreshSearchIndices(new SubProgressMonitor(monitor, 90));
			history.checkConsistency(new SubProgressMonitor(monitor, 10));
		} else {
			refreshSearchIndices(monitor);
		}
		monitor.done();
		fgFirstTime= false;
	} else {
		history.checkConsistency(monitor);
	}
}
 
Example #15
Source File: FilteredTypesSelectionDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected IStatus validateItem(Object item) {

	if (item == null)
		return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.ERROR, "", null); //$NON-NLS-1$

	if (fValidator != null) {
		IType type= ((TypeNameMatch) item).getType();
		if (!type.exists()) {
			String qualifiedName= TypeNameMatchLabelProvider.getText((TypeNameMatch) item, TypeNameMatchLabelProvider.SHOW_FULLYQUALIFIED);
			return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.ERROR, Messages.format(JavaUIMessages.FilteredTypesSelectionDialog_error_type_doesnot_exist, qualifiedName), null);
		}
		Object[] elements= { type };
		return fValidator.validate(elements);
	} else
		return Status.OK_STATUS;
}
 
Example #16
Source File: FilteredTypesSelectionDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void setResult(List newResult) {

	List<IType> resultToReturn= new ArrayList<IType>();

	for (int i= 0; i < newResult.size(); i++) {
		if (newResult.get(i) instanceof TypeNameMatch) {
			IType type= ((TypeNameMatch) newResult.get(i)).getType();
			if (type.exists()) {
				// items are added to history in the
				// org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#computeResult()
				// method
				resultToReturn.add(type);
			} else {
				TypeNameMatch typeInfo= (TypeNameMatch) newResult.get(i);
				IPackageFragmentRoot root= typeInfo.getPackageFragmentRoot();
				String containerName= JavaElementLabels.getElementLabel(root, JavaElementLabels.ROOT_QUALIFIED);
				String message= Messages.format(JavaUIMessages.FilteredTypesSelectionDialog_dialogMessage, new String[] { TypeNameMatchLabelProvider.getText(typeInfo, TypeNameMatchLabelProvider.SHOW_FULLYQUALIFIED), containerName });
				MessageDialog.openError(getShell(), fTitle, message);
				getSelectionHistory().remove(typeInfo);
			}
		}
	}

	super.setResult(resultToReturn);
}
 
Example #17
Source File: GenerateToStringDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected Composite createSelectionButtons(Composite composite) {
	Composite buttonComposite= super.createSelectionButtons(composite);

	GridLayout layout= new GridLayout();
	buttonComposite.setLayout(layout);

	createUpDownButtons(buttonComposite);
	
	createButton(buttonComposite, SORT_BUTTON, JavaUIMessages.GenerateToStringDialog_sort_button, false);

	layout.marginHeight= 0;
	layout.marginWidth= 0;
	layout.numColumns= 1;

	return buttonComposite;
}
 
Example #18
Source File: OverrideMethodDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected CheckboxTreeViewer createTreeViewer(Composite composite) {
	initializeDialogUnits(composite);
	ViewerPane pane= new ViewerPane(composite, SWT.BORDER | SWT.FLAT);
	pane.setText(JavaUIMessages.OverrideMethodDialog_dialog_description);
	CheckboxTreeViewer treeViewer= super.createTreeViewer(pane);
	pane.setContent(treeViewer.getControl());
	GridLayout paneLayout= new GridLayout();
	paneLayout.marginHeight= 0;
	paneLayout.marginWidth= 0;
	paneLayout.numColumns= 1;
	pane.setLayout(paneLayout);
	GridData gd= new GridData(GridData.FILL_BOTH);
	gd.widthHint= convertWidthInCharsToPixels(55);
	gd.heightHint= convertHeightInCharsToPixels(15);
	pane.setLayoutData(gd);
	ToolBarManager manager= pane.getToolBarManager();
	manager.add(new OverrideFlatTreeAction()); // create after tree is created
	manager.update(true);
	treeViewer.getTree().setFocus();
	return treeViewer;
}
 
Example #19
Source File: GenerateHashCodeEqualsDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public GenerateHashCodeEqualsDialog(Shell shell, CompilationUnitEditor editor, IType type, IVariableBinding[] allFields, IVariableBinding[] selectedFields) throws JavaModelException {
	super(shell, new BindingLabelProvider(), new GenerateHashCodeEqualsContentProvider(allFields), editor, type, false);
	setEmptyListMessage(JavaUIMessages.GenerateHashCodeEqualsDialog_no_entries);

	setInitialSelections(selectedFields);

	setTitle(JavaUIMessages.GenerateHashCodeEqualsDialog_dialog_title);
	setMessage(JavaUIMessages.GenerateHashCodeEqualsDialog_select_fields_to_include);
	setValidator(new GenerateHashCodeEqualsValidator(allFields.length));
	setSize(60, 18);
	setInput(new Object());

	fUseInstanceOf= asBoolean(getDialogSettings().get(SETTINGS_INSTANCEOF), false);
	fUseBlocks= asBoolean(getDialogSettings().get(SETTINGS_BLOCKS), false);
}
 
Example #20
Source File: JavaElementLabelComposer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void appendExternalArchiveLabel(IPackageFragmentRoot root, long flags) {
	IPath path;
	IClasspathEntry classpathEntry= null;
	try {
		classpathEntry= JavaModelUtil.getClasspathEntry(root);
		IPath rawPath= classpathEntry.getPath();
		if (classpathEntry.getEntryKind() != IClasspathEntry.CPE_CONTAINER && !rawPath.isAbsolute())
			path= rawPath;
		else
			path= root.getPath();
	} catch (JavaModelException e) {
		path= root.getPath();
	}
	if (getFlag(flags, JavaElementLabels.REFERENCED_ROOT_POST_QUALIFIED)) {
		int segements= path.segmentCount();
		if (segements > 0) {
			fBuffer.append(path.segment(segements - 1));
			int offset= fBuffer.length();
			if (segements > 1 || path.getDevice() != null) {
				fBuffer.append(JavaElementLabels.CONCAT_STRING);
				fBuffer.append(path.removeLastSegments(1).toOSString());
			}
			if (classpathEntry != null) {
				IClasspathEntry referencingEntry= classpathEntry.getReferencingEntry();
				if (referencingEntry != null) {
					fBuffer.append(Messages.format(JavaUIMessages.JavaElementLabels_onClassPathOf, new Object[] { Name.CLASS_PATH.toString(), referencingEntry.getPath().lastSegment() }));
				}
			}
			if (getFlag(flags, JavaElementLabels.COLORIZE)) {
				fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE);
			}
		} else {
			fBuffer.append(path.toOSString());
		}
	} else {
		fBuffer.append(path.toOSString());
	}
}
 
Example #21
Source File: GenerateToStringDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected void createUpDownButtons(Composite buttonComposite) {
	int numButtons= 2; // up, down
	fButtonControls= new Button[numButtons];
	fButtonsEnabled= new boolean[numButtons];
	fButtonControls[UP_INDEX]= createButton(buttonComposite, UP_BUTTON, JavaUIMessages.GenerateToStringDialog_up_button, false);
	fButtonControls[DOWN_INDEX]= createButton(buttonComposite, DOWN_BUTTON, JavaUIMessages.GenerateToStringDialog_down_button, false);
	boolean defaultState= false;
	fButtonControls[UP_INDEX].setEnabled(defaultState);
	fButtonControls[DOWN_INDEX].setEnabled(defaultState);
	fButtonsEnabled[UP_INDEX]= defaultState;
	fButtonsEnabled[DOWN_INDEX]= defaultState;
}
 
Example #22
Source File: FilteredTypesSelectionDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public String getQualifiedText(TypeNameMatch type) {
	StringBuffer result= new StringBuffer();
	result.append(type.getSimpleTypeName());
	String containerName= type.getTypeContainerName();
	result.append(JavaElementLabels.CONCAT_STRING);
	if (containerName.length() > 0) {
		result.append(containerName);
	} else {
		result.append(JavaUIMessages.FilteredTypesSelectionDialog_default_package);
	}
	return result.toString();
}
 
Example #23
Source File: ExceptionHandler.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void displayMessageDialog(String exceptionMessage, Shell shell, String title, String message) {
	StringWriter msg= new StringWriter();
	if (message != null) {
		msg.write(message);
		msg.write("\n\n"); //$NON-NLS-1$
	}
	if (exceptionMessage == null || exceptionMessage.length() == 0)
		msg.write(JavaUIMessages.ExceptionDialog_seeErrorLogMessage);
	else
		msg.write(exceptionMessage);
	MessageDialog.openError(shell, title, msg.toString());
}
 
Example #24
Source File: ElementValidator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static boolean checkInSync(IResource[] resources, Shell parent, String title) {
	IStatus status= Resources.checkInSync(resources);
	if (status.isOK())
		return true;
	ErrorDialog.openError(parent, title,
		JavaUIMessages.ElementValidator_cannotPerform,
		status);
	return false;
}
 
Example #25
Source File: FilteredTypesSelectionDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void fillContentProvider(AbstractContentProvider provider, ItemsFilter itemsFilter, IProgressMonitor progressMonitor) throws CoreException {
	TypeItemsFilter typeSearchFilter= (TypeItemsFilter) itemsFilter;
	TypeSearchRequestor requestor= new TypeSearchRequestor(provider, typeSearchFilter);
	SearchEngine engine= new SearchEngine((WorkingCopyOwner) null);
	String packPattern= typeSearchFilter.getPackagePattern();
	progressMonitor.setTaskName(JavaUIMessages.FilteredTypesSelectionDialog_searchJob_taskName);

	/*
	 * Setting the filter into match everything mode avoids filtering twice
	 * by the same pattern (the search engine only provides filtered
	 * matches). For the case when the pattern is a camel case pattern with
	 * a terminator, the filter is not set to match everything mode because
	 * jdt.core's SearchPattern does not support that case.
	 */
	String typePattern= typeSearchFilter.getNamePattern();
	int matchRule= typeSearchFilter.getMatchRule();
	typeSearchFilter.setMatchEverythingMode(true);

	try {
		engine.searchAllTypeNames(packPattern == null ? null : packPattern.toCharArray(),
				typeSearchFilter.getPackageFlags(),
				typePattern.toCharArray(),
				matchRule,
				typeSearchFilter.getElementKind(),
				typeSearchFilter.getSearchScope(),
				requestor,
				IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
				progressMonitor);
	} finally {
		typeSearchFilter.setMatchEverythingMode(false);
	}
}
 
Example #26
Source File: ElementValidator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static boolean checkValidateEdit(IResource[] resources, Shell parent, String title) {
	IStatus status= Resources.makeCommittable(resources, parent);
	if (!status.isOK()) {
		ErrorDialog.openError(parent, title,
			JavaUIMessages.ElementValidator_cannotPerform,
			status);
		return false;
	}
	return true;
}
 
Example #27
Source File: FilteredTypesSelectionDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Adds or replaces subtitle of the dialog
 *
 * @param text
 *            the new subtitle for this dialog
 */
private void setSubtitle(String text) {
	if (text == null || text.length() == 0) {
		getShell().setText(fTitle);
	} else {
		getShell().setText(Messages.format(JavaUIMessages.FilteredTypeSelectionDialog_titleFormat, new String[] { fTitle, text }));
	}
}
 
Example #28
Source File: GenerateHashCodeEqualsDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public IStatus validate(Object[] selection) {
	int count= 0;
	for (int index= 0; index < selection.length; index++) {
		if (selection[index] instanceof IVariableBinding)
			count++;
	}
	if (count == 0)
		return new StatusInfo(IStatus.ERROR, JavaUIMessages.GenerateHashCodeEqualsDialog_select_at_least_one_field);

	return new StatusInfo(IStatus.INFO, Messages.format(JavaUIMessages.GenerateHashCodeEqualsDialog_selectioninfo_more, new String[] { String.valueOf(count), String.valueOf(fNumFields)}));
}
 
Example #29
Source File: AbstractConversionTable.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Create a cell editor that enables to select a class.
 *
 * @return the cell editor.
 */
protected CellEditor createClassCellEditor() {
	return new DialogCellEditor(getControl()) {
		@Override
		protected Object openDialogBox(Control cellEditorWindow) {
			final OpenTypeSelectionDialog dialog = new OpenTypeSelectionDialog(
					getControl().getShell(),
					false,
					PlatformUI.getWorkbench().getProgressService(),
					null,
					IJavaSearchConstants.TYPE);
			dialog.setTitle(JavaUIMessages.OpenTypeAction_dialogTitle);
			dialog.setMessage(JavaUIMessages.OpenTypeAction_dialogMessage);
			final int result = dialog.open();
			if (result != IDialogConstants.OK_ID) {
				return null;
			}
			final Object[] types = dialog.getResult();
			if (types == null || types.length != 1 || !(types[0] instanceof IType)) {
				return null;
			}
			final IType type = (IType) types[0];
			final String name = type.getFullyQualifiedName();
			return Strings.emptyIfNull(name);
		}
	};
}
 
Example #30
Source File: GenerateToStringDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private String createNewTemplateName() {
	if (!templateNames.contains(JavaUIMessages.GenerateToStringDialog_newTemplateName))
		return JavaUIMessages.GenerateToStringDialog_newTemplateName;

	int copyCount= 2;
	String newName;
	do {
		newName= Messages.format(JavaUIMessages.GenerateToStringDialog_newTemplateNameArg, new Integer(copyCount));
		copyCount++;
	} while (templateNames.contains(newName));
	return newName;
}