Java Code Examples for org.eclipse.jdt.internal.corext.util.Messages

The following examples show how to use org.eclipse.jdt.internal.corext.util.Messages. These examples are extracted from open source projects. 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
private RefactoringStatus checkEnclosingHierarchy() {
	IType current= fField.getDeclaringType();
	if (Checks.isTopLevel(current))
		return null;
	RefactoringStatus result= new RefactoringStatus();
	while (current != null){
		IField otherField= current.getField(getNewElementName());
		if (otherField.exists()){
			String msg= Messages.format(RefactoringCoreMessages.RenameFieldRefactoring_hiding2,
			 	new String[]{ BasicElementLabels.getJavaElementName(getNewElementName()), BasicElementLabels.getJavaElementName(current.getFullyQualifiedName('.')), BasicElementLabels.getJavaElementName(otherField.getElementName())});
			result.addWarning(msg, JavaStatusContext.create(otherField));
		}
		current= current.getDeclaringType();
	}
	return result;
}
 
Example 2
public String getColumnText(Object element, int columnIndex) {
	TodoTask task= (TodoTask) element;
	if (columnIndex == 0) {
		String name= task.name;
		if (isDefaultTask(task)) {
			name=Messages.format(PreferencesMessages.TodoTaskConfigurationBlock_tasks_default, name);
		}
		return name;
	} else {
		if (PRIORITY_HIGH.equals(task.priority)) {
			return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_high_priority;
		} else if (PRIORITY_NORMAL.equals(task.priority)) {
			return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_normal_priority;
		} else if (PRIORITY_LOW.equals(task.priority)) {
			return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_low_priority;
		}
		return ""; //$NON-NLS-1$
	}
}
 
Example 3
private RefactoringStatus checkPackageName(String newName) throws CoreException {
	RefactoringStatus status= new RefactoringStatus();
	IPackageFragmentRoot[] roots= fPackage.getJavaProject().getPackageFragmentRoots();
	Set<String> topLevelTypeNames= getTopLevelTypeNames();
	for (int i= 0; i < roots.length; i++) {
		IPackageFragmentRoot root= roots[i];
		if (! isPackageNameOkInRoot(newName, root)) {
			String rootLabel = JavaElementLabels.getElementLabel(root, JavaElementLabels.ALL_DEFAULT);
			String newPackageName= BasicElementLabels.getJavaElementName(getNewElementName());
			String message= Messages.format(RefactoringCoreMessages.RenamePackageRefactoring_aleady_exists, new Object[]{ newPackageName, rootLabel});
			status.merge(RefactoringStatus.createWarningStatus(message));
			status.merge(checkTypeNameConflicts(root, newName, topLevelTypeNames));
		}
	}
	return status;
}
 
Example 4
/**
 * @param classpathEntries the path to the package fragment roots
 * @param projectName the root of the project dependency tree
 * @param status a status to report problems to
 * @return all package fragment roots corresponding to each classpath entry start the search at project with projectName
 */
private static IPackageFragmentRoot[] getRequiredPackageFragmentRoots(IPath[] classpathEntries, final String projectName, MultiStatus status) {
	ArrayList<IPackageFragmentRoot> result= new ArrayList<IPackageFragmentRoot>();

	IJavaProject[] searchOrder= getProjectSearchOrder(projectName);

	for (int i= 0; i < classpathEntries.length; i++) {
		IPath entry= classpathEntries[i];
		IPackageFragmentRoot[] elements= findRootsForClasspath(entry, searchOrder);
		if (elements == null) {
			status.add(new Status(IStatus.WARNING, JavaUI.ID_PLUGIN, Messages.format(FatJarPackagerMessages.FatJarPackageWizardPage_error_missingClassFile, BasicElementLabels.getPathLabel(entry, false))));
		} else {
			for (int j= 0; j < elements.length; j++) {
				result.add(elements[j]);
			}
		}
	}

	return result.toArray(new IPackageFragmentRoot[result.size()]);
}
 
Example 5
private String getDescriptionString() {
	String desc;
	String name= BasicElementLabels.getResourceName(fCurrElement.getPath().lastSegment());
	switch (fCurrElement.getEntryKind()) {
		case IClasspathEntry.CPE_CONTAINER:
			try {
				name= JavaElementLabels.getContainerEntryLabel(fCurrElement.getPath(), fCurrElement.getJavaProject());
			} catch (JavaModelException e) {
			}
			desc= NewWizardMessages.AccessRulesDialog_container_description;
			break;
		case IClasspathEntry.CPE_PROJECT:
			desc=  NewWizardMessages.AccessRulesDialog_project_description;
			break;
		default:
			desc=  NewWizardMessages.AccessRulesDialog_description;
	}

	return Messages.format(desc, name);
}
 
Example 6
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 7
/**
 * {@inheritDoc}
 */
@Override
public String getDetailedDescription() {
	if (!isEnabled())
		return null;

	if (getSelectedElements().size() != 1)
		return NewWizardMessages.PackageExplorerActionGroup_FormText_Default_toBuildpath;

	Object obj= getSelectedElements().get(0);
	String elementLabel= JavaElementLabels.getTextLabel(obj, JavaElementLabels.ALL_DEFAULT);
	if (obj instanceof IJavaProject) {
		return Messages.format(NewWizardMessages.PackageExplorerActionGroup_FormText_ProjectToBuildpath, elementLabel);
	} else if (obj instanceof IPackageFragment) {
		return Messages.format(NewWizardMessages.PackageExplorerActionGroup_FormText_PackageToBuildpath, elementLabel);
	} else if (obj instanceof IResource) {
		return Messages.format(NewWizardMessages.PackageExplorerActionGroup_FormText_FolderToBuildpath, elementLabel);
	}

	return null;
}
 
Example 8
public void rewriteVisibility(final MemberVisibilityAdjustor adjustor, final IProgressMonitor monitor) throws JavaModelException {
	Assert.isNotNull(adjustor);
	Assert.isNotNull(monitor);
	try {
		monitor.beginTask("", 1); //$NON-NLS-1$
		monitor.setTaskName(RefactoringCoreMessages.MemberVisibilityAdjustor_adjusting);
		if (fNeedsRewriting) {
			if (adjustor.fRewrite != null && adjustor.fRoot != null)
				rewriteVisibility(adjustor, adjustor.fRewrite, adjustor.fRoot, null, fRefactoringStatus);
			else {
				final CompilationUnitRewrite rewrite= adjustor.getCompilationUnitRewrite(fMember.getCompilationUnit());
				rewriteVisibility(adjustor, rewrite.getASTRewrite(), rewrite.getRoot(), rewrite.createCategorizedGroupDescription(Messages.format(RefactoringCoreMessages.MemberVisibilityAdjustor_change_visibility, getLabel(getKeyword())), SET_VISIBILITY_ADJUSTMENTS), fRefactoringStatus);
			}
		} else if (fRefactoringStatus != null)
			adjustor.fStatus.merge(fRefactoringStatus);
		monitor.worked(1);
	} finally {
		monitor.done();
	}
}
 
Example 9
private void addAccessor(NLSSubstitution sub, TextChange change, String accessorName) {
	if (sub.getState() == NLSSubstitution.EXTERNALIZED) {
		NLSElement element= sub.getNLSElement();
		Region position= element.getPosition();
		String[] args= {sub.getValueNonEmpty(), BasicElementLabels.getJavaElementName(sub.getKey())};
		String text= Messages.format(NLSMessages.NLSSourceModifier_externalize, args);

		String resourceGetter= createResourceGetter(sub.getKey(), accessorName);

		TextEdit edit= new ReplaceEdit(position.getOffset(), position.getLength(), resourceGetter);
		if (fIsEclipseNLS && element.getTagPosition() != null) {
			MultiTextEdit multiEdit= new MultiTextEdit();
			multiEdit.addChild(edit);
			Region tagPosition= element.getTagPosition();
			multiEdit.addChild(new DeleteEdit(tagPosition.getOffset(), tagPosition.getLength()));
			edit= multiEdit;
		}
		TextChangeCompatibility.addTextEdit(change, text, edit);
	}
}
 
Example 10
/**
 * {@inheritDoc}
 */
public CompilationUnitChange createChange(IProgressMonitor progressMonitor) throws CoreException {
	CompilationUnitRewrite cuRewrite= new CompilationUnitRewrite((ICompilationUnit)fCompilationUnit.getJavaElement(), fCompilationUnit);

	fLinkedProposalModel.clear();
	for (int i= 0; i < fOperations.length; i++) {
		CompilationUnitRewriteOperation operation= fOperations[i];
		operation.rewriteAST(cuRewrite, fLinkedProposalModel);
	}

	CompilationUnitChange result= cuRewrite.createChange(getDisplayString(), true, null);
	if (result == null)
		throw new CoreException(new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, Messages.format(FixMessages.CompilationUnitRewriteOperationsFix_nullChangeError, getDisplayString())));

	return result;
}
 
Example 11
/**
 * Checks whether the type name is valid.
 *
 * @param name
 *            the name to check
 * @return the status of the condition checking
 */
public final RefactoringStatus checkTypeName(final String name) {
	Assert.isNotNull(name);
	try {
		final RefactoringStatus result= Checks.checkTypeName(name, fSubType);
		if (result.hasFatalError())
			return result;
		final String unitName= JavaModelUtil.getRenamedCUName(fSubType.getCompilationUnit(), name);
		result.merge(Checks.checkCompilationUnitName(unitName, fSubType));
		if (result.hasFatalError())
			return result;
		final IPackageFragment fragment= fSubType.getPackageFragment();
		if (fragment.getCompilationUnit(unitName).exists()) {
			result.addFatalError(Messages.format(RefactoringCoreMessages.ExtractInterfaceProcessor_existing_compilation_unit, new String[] { BasicElementLabels.getResourceName(unitName), JavaElementLabels.getElementLabel(fragment, JavaElementLabels.ALL_DEFAULT) }));
			return result;
		}
		result.merge(checkSuperType());
		return result;
	} catch (JavaModelException exception) {
		return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractInterfaceProcessor_internal_error);
	}
}
 
Example 12
private RefactoringStatus checkOriginalVarargs() throws JavaModelException {
	if (JdtFlags.isVarargs(fMethod))
		fOldVarargIndex= fMethod.getNumberOfParameters() - 1;
	List<ParameterInfo> notDeletedInfos= getNotDeletedInfos();
	for (int i= 0; i < notDeletedInfos.size(); i++) {
		ParameterInfo info= notDeletedInfos.get(i);
		if (info.isOldVarargs() && ! info.isNewVarargs())
			return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.ChangeSignatureRefactoring_cannot_convert_vararg, BasicElementLabels.getJavaElementName(info.getNewName())));
		if (i != notDeletedInfos.size() - 1) {
			// not the last parameter
			if (info.isNewVarargs())
				return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.ChangeSignatureRefactoring_vararg_must_be_last, BasicElementLabels.getJavaElementName(info.getNewName())));
		}
	}
	return null;
}
 
Example 13
private static RefactoringStatus checkKey(String key) {
	RefactoringStatus result= new RefactoringStatus();

	if (key == null)
		result.addFatalError(NLSMessages.NLSRefactoring_null);

	if (key.startsWith("!") || key.startsWith("#")) { //$NON-NLS-1$ //$NON-NLS-2$
		RefactoringStatusContext context= new JavaStringStatusContext(key, new SourceRange(0, 0));
		result.addWarning(NLSMessages.NLSRefactoring_warning, context);
	}

	if ("".equals(key.trim())) //$NON-NLS-1$
		result.addFatalError(NLSMessages.NLSRefactoring_empty);

	final String[] UNWANTED_STRINGS= {" ", ":", "\"", "\\", "'", "?", "="}; //$NON-NLS-7$ //$NON-NLS-6$ //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
	//feature in resource bundle - does not work properly if keys have ":"
	for (int i= 0; i < UNWANTED_STRINGS.length; i++) {
		if (key.indexOf(UNWANTED_STRINGS[i]) != -1) {
			String[] args= {key, UNWANTED_STRINGS[i]};
			String msg= Messages.format(NLSMessages.NLSRefactoring_should_not_contain, args);
			result.addError(msg);
		}
	}
	return result;
}
 
Example 14
private RefactoringStatus checkParameterNamesInRippleMethods() throws JavaModelException {
	RefactoringStatus result= new RefactoringStatus();
	Set<String> newParameterNames= getNewParameterNamesList();
	for (int i= 0; i < fRippleMethods.length; i++) {
		String[] paramNames= fRippleMethods[i].getParameterNames();
		for (int j= 0; j < paramNames.length; j++) {
			if (newParameterNames.contains(paramNames[j])){
				String[] args= new String[]{ JavaElementUtil.createMethodSignature(fRippleMethods[i]), BasicElementLabels.getJavaElementName(paramNames[j])};
				String msg= Messages.format(RefactoringCoreMessages.ChangeSignatureRefactoring_already_has, args);
				RefactoringStatusContext context= JavaStatusContext.create(fRippleMethods[i].getCompilationUnit(), fRippleMethods[i].getNameRange());
				result.addError(msg, context);
			}
		}
	}
	return result;
}
 
Example 15
protected void checkIfDeletedParametersUsed() {
	for (Iterator<ParameterInfo> iter= getDeletedInfos().iterator(); iter.hasNext();) {
		ParameterInfo info= iter.next();
		VariableDeclaration paramDecl= getParameter(info.getOldIndex());
		TempOccurrenceAnalyzer analyzer= new TempOccurrenceAnalyzer(paramDecl, false);
		analyzer.perform();
		SimpleName[] paramRefs= analyzer.getReferenceNodes();

		if (paramRefs.length > 0) {
			RefactoringStatusContext context= JavaStatusContext.create(fCuRewrite.getCu(), paramRefs[0]);
			String typeName= getFullTypeName();
			Object[] keys= new String[] { BasicElementLabels.getJavaElementName(paramDecl.getName().getIdentifier()),
					BasicElementLabels.getJavaElementName(getMethod().getElementName()),
					BasicElementLabels.getJavaElementName(typeName) };
			String msg= Messages.format(RefactoringCoreMessages.ChangeSignatureRefactoring_parameter_used, keys);
			fResult.addError(msg, context);
		}
	}
}
 
Example 16
@Override
protected void updateWidget() {
    final boolean hasKey= getKey() != null;

    fNumberLabel.setEnabled(hasKey && getEnabled());
	fNumberText.setEnabled(hasKey && getEnabled());

	if (hasKey) {
	    String s= getPreferences().get(getKey());
	    try {
	        fSelected= Integer.parseInt(s);
	    } catch (NumberFormatException e) {
	        final String message= Messages.format(FormatterMessages.ModifyDialogTabPage_NumberPreference_error_invalid_key, getKey());
	        JavaPlugin.log(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, message, e));
	        s= ""; //$NON-NLS-1$
	    }
	    fNumberText.setText(s);
	} else {
	    fNumberText.setText(""); //$NON-NLS-1$
	}
}
 
Example 17
private static String getDisplayString(SimpleName simpleName, IBinding binding, boolean removeAllAssignements) {
	String name= BasicElementLabels.getJavaElementName(simpleName.getIdentifier());
	switch (binding.getKind()) {
		case IBinding.TYPE:
			return Messages.format(FixMessages.UnusedCodeFix_RemoveType_description, name);
		case IBinding.METHOD:
			if (((IMethodBinding) binding).isConstructor()) {
				return Messages.format(FixMessages.UnusedCodeFix_RemoveConstructor_description, name);
			} else {
				return Messages.format(FixMessages.UnusedCodeFix_RemoveMethod_description, name);
			}
		case IBinding.VARIABLE:
			if (removeAllAssignements) {
				return Messages.format(FixMessages.UnusedCodeFix_RemoveFieldOrLocalWithInitializer_description, name);
			} else {
				return Messages.format(FixMessages.UnusedCodeFix_RemoveFieldOrLocal_description, name);
			}
		default:
			return ""; //$NON-NLS-1$
	}
}
 
Example 18
private IClasspathEntry handleContainerEntry(IPath containerPath, IJavaProject jproject, IPath jarPath) throws JavaModelException {
	ClasspathContainerInitializer initializer= JavaCore.getClasspathContainerInitializer(containerPath.segment(0));
	IClasspathContainer container= JavaCore.getClasspathContainer(containerPath, jproject);
	if (initializer == null || container == null) {
		setDescription(Messages.format(PreferencesMessages.NativeLibrariesPropertyPage_invalid_container, BasicElementLabels.getPathLabel(containerPath, false)));
		return null;
	}
	String containerName= container.getDescription();
	IStatus status= initializer.getAttributeStatus(containerPath, jproject, JavaRuntime.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY);
	if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_NOT_SUPPORTED) {
		setDescription(Messages.format(PreferencesMessages.NativeLibrariesPropertyPage_not_supported, containerName));
		return null;
	}
	IClasspathEntry entry= JavaModelUtil.findEntryInContainer(container, jarPath);
	if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_READ_ONLY) {
		setDescription(Messages.format(PreferencesMessages.NativeLibrariesPropertyPage_read_only, containerName));
		fIsReadOnly= true;
		return entry;
	}
	Assert.isNotNull(entry);
	return entry;
}
 
Example 19
public static void getAmbiguosTypeReferenceProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) throws CoreException {
	final ICompilationUnit cu= context.getCompilationUnit();
	int offset= problem.getOffset();
	int len= problem.getLength();

	IJavaElement[] elements= cu.codeSelect(offset, len);
	for (int i= 0; i < elements.length; i++) {
		IJavaElement curr= elements[i];
		if (curr instanceof IType && !TypeFilter.isFiltered((IType) curr)) {
			String qualifiedTypeName= ((IType) curr).getFullyQualifiedName('.');

			CompilationUnit root= context.getASTRoot();

			String label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_importexplicit_description, BasicElementLabels.getJavaElementName(qualifiedTypeName));
			Image image= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_IMPDECL);
			ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, cu, ASTRewrite.create(root.getAST()), IProposalRelevance.IMPORT_EXPLICIT, image);

			ImportRewrite imports= proposal.createImportRewrite(root);
			imports.addImport(qualifiedTypeName);

			proposals.add(proposal);
		}
	}
}
 
Example 20
public String createNewName(ICompilationUnit cu, IPackageFragment destination) {
	if (isNewNameOk(destination, cu.getElementName()))
		return null;
	if (!ReorgUtils.isParentInWorkspaceOrOnDisk(cu, destination))
		return null;
	int i= 1;
	while (true) {
		String newName;
		if (i == 1)
			newName= Messages.format(RefactoringCoreMessages.CopyRefactoring_cu_copyOf1, cu.getElementName()); // Don't use BasicElementLabels! No RTL!
		else
			newName= Messages.format(RefactoringCoreMessages.CopyRefactoring_cu_copyOfMore, new String[] { String.valueOf(i), cu.getElementName()}); // Don't use BasicElementLabels! No RTL!
		if (isNewNameOk(destination, newName) && !fAutoGeneratedNewNames.contains(newName)) {
			fAutoGeneratedNewNames.add(newName);
			return JavaCore.removeJavaLikeExtension(newName);
		}
		i++;
	}
}
 
Example 21
@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 22
private RefactoringStatus checkNestedHierarchy(IType type) throws CoreException {
	IType[] nestedTypes= type.getTypes();
	if (nestedTypes == null)
		return null;
	RefactoringStatus result= new RefactoringStatus();
	for (int i= 0; i < nestedTypes.length; i++){
		IField otherField= nestedTypes[i].getField(getNewElementName());
		if (otherField.exists()){
			String msg= Messages.format(
				RefactoringCoreMessages.RenameFieldRefactoring_hiding,
				new String[]{ BasicElementLabels.getJavaElementName(fField.getElementName()), BasicElementLabels.getJavaElementName(getNewElementName()), BasicElementLabels.getJavaElementName(nestedTypes[i].getFullyQualifiedName('.'))});
			result.addWarning(msg, JavaStatusContext.create(otherField));
		}
		result.merge(checkNestedHierarchy(nestedTypes[i]));
	}
	return result;
}
 
Example 23
private void editSelectedMembers() {
	if (!fEditButton.isEnabled())
		return;

	final ISelection preserved= fTableViewer.getSelection();
	try {
		MemberActionInfo[] selectedMembers= getSelectedMembers();
		final String shellTitle= RefactoringMessages.PullUpInputPage1_Edit_members;
		final String labelText= selectedMembers.length == 1
				? Messages.format(RefactoringMessages.PullUpInputPage1_Mark_selected_members_singular, JavaElementLabels.getElementLabel(selectedMembers[0].getMember(),
						JavaElementLabels.M_PARAMETER_TYPES))
				: Messages.format(RefactoringMessages.PullUpInputPage1_Mark_selected_members_plural, String.valueOf(selectedMembers.length));
		final Map<String, Integer> stringMapping= createStringMappingForSelectedMembers();
		final String[] keys= stringMapping.keySet().toArray(new String[stringMapping.keySet().size()]);
		Arrays.sort(keys);
		final int initialSelectionIndex= getInitialSelectionIndexForEditDialog(stringMapping, keys);
		final ComboSelectionDialog dialog= new ComboSelectionDialog(getShell(), shellTitle, labelText, keys, initialSelectionIndex);
		dialog.setBlockOnOpen(true);
		if (dialog.open() == Window.CANCEL)
			return;
		final int action= stringMapping.get(dialog.getSelectedString()).intValue();
		setActionForInfos(selectedMembers, action);
	} finally {
		updateWizardPage(preserved, true);
	}
}
 
Example 24
/**
 * Creates a new <code>ViewerFilter</code>.
 * This method is only valid for viewer filters.
 * @return a new <code>ViewerFilter</code>
 */
public ViewerFilter createViewerFilter() {
	if (!isCustomFilter())
		return null;

	final ViewerFilter[] result= new ViewerFilter[1];
	String message= Messages.format(FilterMessages.FilterDescriptor_filterCreationError_message, getId());
	ISafeRunnable code= new SafeRunnable(message) {
		/*
		 * @see org.eclipse.core.runtime.ISafeRunnable#run()
		 */
		public void run() throws Exception {
			result[0]= (ViewerFilter)fElement.createExecutableExtension(CLASS_ATTRIBUTE);
		}

	};
	SafeRunner.run(code);
	return result[0];
}
 
Example 25
@Override
public String getText(Object element) {
	if (isSimilarElement(element)) {
		return Messages.format(RefactoringMessages.RenameTypeWizardSimilarElementsPage_rename_to, new String[] { super.getText(element), fElementToNewName.get(element) } );
	}
	return super.getText(element);
}
 
Example 26
public static RefactoringStatus checkIfComesFromInterface(IMethod method, ITypeHierarchy hierarchy, IProgressMonitor monitor) throws JavaModelException {
	IMethod inInterface= MethodChecks.isDeclaredInInterface(method, hierarchy, monitor);

	if (inInterface == null)
		return null;

	RefactoringStatusContext context= JavaStatusContext.create(inInterface);
	String message= Messages.format(RefactoringCoreMessages.MethodChecks_implements,
			new String[]{JavaElementUtil.createMethodSignature(inInterface), JavaElementLabels.getElementLabel(inInterface.getDeclaringType(), JavaElementLabels.ALL_FULLY_QUALIFIED)});
	return RefactoringStatus.createStatus(RefactoringStatus.FATAL, message, context, Corext.getPluginId(), RefactoringStatusCodes.METHOD_DECLARED_IN_INTERFACE, inInterface);
}
 
Example 27
private ExtractConstantDescriptor createRefactoringDescriptor() {
	final Map<String, String> arguments= new HashMap<String, String>();
	String project= null;
	IJavaProject javaProject= fCu.getJavaProject();
	if (javaProject != null)
		project= javaProject.getElementName();
	int flags= JavaRefactoringDescriptor.JAR_REFACTORING | JavaRefactoringDescriptor.JAR_SOURCE_ATTACHMENT;
	if (JdtFlags.getVisibilityCode(fVisibility) != Modifier.PRIVATE)
		flags|= RefactoringDescriptor.STRUCTURAL_CHANGE;

	final String expression= ASTNodes.asString(fSelectedExpression.getAssociatedExpression());
	final String description= Messages.format(RefactoringCoreMessages.ExtractConstantRefactoring_descriptor_description_short, BasicElementLabels.getJavaElementName(fConstantName));
	final String header= Messages.format(RefactoringCoreMessages.ExtractConstantRefactoring_descriptor_description, new String[] { BasicElementLabels.getJavaElementName(fConstantName), BasicElementLabels.getJavaCodeString(expression)});
	final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(project, this, header);
	comment.addSetting(Messages.format(RefactoringCoreMessages.ExtractConstantRefactoring_constant_name_pattern, BasicElementLabels.getJavaElementName(fConstantName)));
	comment.addSetting(Messages.format(RefactoringCoreMessages.ExtractConstantRefactoring_constant_expression_pattern, BasicElementLabels.getJavaCodeString(expression)));
	String visibility= fVisibility;
	if ("".equals(visibility)) //$NON-NLS-1$
		visibility= RefactoringCoreMessages.ExtractConstantRefactoring_default_visibility;
	comment.addSetting(Messages.format(RefactoringCoreMessages.ExtractConstantRefactoring_visibility_pattern, visibility));
	if (fReplaceAllOccurrences)
		comment.addSetting(RefactoringCoreMessages.ExtractConstantRefactoring_replace_occurrences);
	if (fQualifyReferencesWithDeclaringClassName)
		comment.addSetting(RefactoringCoreMessages.ExtractConstantRefactoring_qualify_references);
	arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, JavaRefactoringDescriptorUtil.elementToHandle(project, fCu));
	arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME, fConstantName);
	arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, new Integer(fSelectionStart).toString() + " " + new Integer(fSelectionLength).toString()); //$NON-NLS-1$
	arguments.put(ATTRIBUTE_REPLACE, Boolean.valueOf(fReplaceAllOccurrences).toString());
	arguments.put(ATTRIBUTE_QUALIFY, Boolean.valueOf(fQualifyReferencesWithDeclaringClassName).toString());
	arguments.put(ATTRIBUTE_VISIBILITY, new Integer(JdtFlags.getVisibilityCode(fVisibility)).toString());

	ExtractConstantDescriptor descriptor= RefactoringSignatureDescriptorFactory.createExtractConstantDescriptor(project, description, comment.asString(), arguments, flags);
	return descriptor;
}
 
Example 28
public StyledString getStyledDisplayString() {
	StyledString str= new StyledString(fLabel);

	String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
	if (shortCutString != null) {
		String decorated= Messages.format(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut, new String[] { fLabel, shortCutString });
		return StyledCellLabelProvider.styleDecoratedString(decorated, StyledString.QUALIFIER_STYLER, str);
	}
	return str;
}
 
Example 29
NonNLSListDialog(Shell parent, NonNLSElement[] input, int count) {
	super(parent);
	setAddCancelButton(false);
	setInput(Arrays.asList(input));
	setTitle(ActionMessages.ExternalizeStringsAction_dialog_title);
	String message= count == 1 ? ActionMessages.FindStringsToExternalizeAction_non_externalized_singular : Messages.format(
			ActionMessages.FindStringsToExternalizeAction_non_externalized_plural, new Object[] { new Integer(count) });
	setMessage(message);
	setContentProvider(new ArrayContentProvider());
	setLabelProvider(createLabelProvider());
}
 
Example 30
private void createLocationInput(Composite parent) {
	Label l= new Label(parent, SWT.NONE);
	l.setText(RefactoringMessages.ExtractClassWizard_label_destination);

	Composite composite= new Composite(parent, SWT.None);
	GridLayout gridLayout= new GridLayout(2, false);
	gridLayout.marginHeight= 0;
	gridLayout.marginWidth= 0;
	composite.setLayout(gridLayout);

	GridData gridData= new GridData(GridData.FILL_HORIZONTAL);
	gridData.horizontalIndent= FieldDecorationRegistry.getDefault().getMaximumDecorationWidth();
	composite.setLayoutData(gridData);

	final Button topLvlRadio= new Button(composite, SWT.RADIO);
	topLvlRadio.setText(RefactoringMessages.ExtractClassWizard_radio_top_level);
	topLvlRadio.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			boolean fAsTopLevel= topLvlRadio.getSelection();
			fDescriptor.setCreateTopLevel(fAsTopLevel);
			validateRefactoring();
		}
	});

	Button nestedRadio= new Button(composite, SWT.RADIO);
	nestedRadio.setText(Messages.format(RefactoringMessages.ExtractClassWizard_radio_nested, JavaElementLabels.getElementLabel(fDescriptor.getType(), JavaElementLabels.ALL_DEFAULT)));

	boolean createAsTopLevel= getBooleanSetting(CREATE_TOP_LEVEL_SETTING, fDescriptor.isCreateTopLevel());
	fDescriptor.setCreateTopLevel(createAsTopLevel);
	topLvlRadio.setSelection(createAsTopLevel);
	nestedRadio.setSelection(!createAsTopLevel);

}