org.eclipse.jdt.ui.cleanup.CleanUpOptions Java Examples
The following examples show how to use
org.eclipse.jdt.ui.cleanup.CleanUpOptions.
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: QuickAssistProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static boolean getConvertIterableLoopProposal(IInvocationContext context, ASTNode node, Collection<ICommandAccess> resultingCollections) { ForStatement forStatement= getEnclosingForStatementHeader(node); if (forStatement == null) return false; if (resultingCollections == null) return true; IProposableFix fix= ConvertLoopFix.createConvertIterableLoopToEnhancedFix(context.getASTRoot(), forStatement); if (fix == null) return false; Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); Map<String, String> options= new HashMap<String, String>(); options.put(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED, CleanUpOptions.TRUE); ICleanUp cleanUp= new ConvertLoopCleanUp(options); FixCorrectionProposal proposal= new FixCorrectionProposal(fix, cleanUp, IProposalRelevance.CONVERT_ITERABLE_LOOP_TO_ENHANCED, image, context); proposal.setCommandId(CONVERT_FOR_LOOP_ID); resultingCollections.add(proposal); return true; }
Example #2
Source File: CleanUpRefactoringWizard.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void initializeRefactoring() { CleanUpRefactoring refactoring= (CleanUpRefactoring)getRefactoring(); CleanUpOptions options= null; if (fUseCustomField.isSelected()) { refactoring.setUseOptionsFromProfile(false); options= new MapCleanUpOptions(fCustomSettings); } else { refactoring.setUseOptionsFromProfile(true); } refactoring.clearCleanUps(); ICleanUp[] cleanups= JavaPlugin.getDefault().getCleanUpRegistry().createCleanUps(); for (int i= 0; i < cleanups.length; i++) { if (options != null) cleanups[i].setOptions(options); refactoring.addCleanUp(cleanups[i]); } }
Example #3
Source File: CleanUpRefactoringWizard.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void showCustomSettings(BulletListBlock bulletListBlock) { StringBuffer buf= new StringBuffer(); final ICleanUp[] cleanUps= JavaPlugin.getDefault().getCleanUpRegistry().createCleanUps(); CleanUpOptions options= new MapCleanUpOptions(fCustomSettings); for (int i= 0; i < cleanUps.length; i++) { cleanUps[i].setOptions(options); String[] descriptions= cleanUps[i].getStepDescriptions(); if (descriptions != null) { for (int j= 0; j < descriptions.length; j++) { if (buf.length() > 0) { buf.append('\n'); } buf.append(descriptions[j]); } } } bulletListBlock.setText(buf.toString()); }
Example #4
Source File: QuickAssistProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static boolean getMakeVariableDeclarationFinalProposals(IInvocationContext context, Collection<ICommandAccess> resultingCollections) { SelectionAnalyzer analyzer= new SelectionAnalyzer(Selection.createFromStartLength(context.getSelectionOffset(), context.getSelectionLength()), false); context.getASTRoot().accept(analyzer); ASTNode[] selectedNodes= analyzer.getSelectedNodes(); if (selectedNodes.length == 0) return false; IProposableFix fix= VariableDeclarationFix.createChangeModifierToFinalFix(context.getASTRoot(), selectedNodes); if (fix == null) return false; if (resultingCollections == null) return true; Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); Map<String, String> options= new Hashtable<String, String>(); options.put(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL, CleanUpOptions.TRUE); options.put(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_LOCAL_VARIABLES, CleanUpOptions.TRUE); options.put(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_PARAMETERS, CleanUpOptions.TRUE); options.put(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_PRIVATE_FIELDS, CleanUpOptions.TRUE); VariableDeclarationCleanUp cleanUp= new VariableDeclarationCleanUp(options); FixCorrectionProposal proposal= new FixCorrectionProposal(fix, cleanUp, IProposalRelevance.MAKE_VARIABLE_DECLARATION_FINAL, image, context); resultingCollections.add(proposal); return true; }
Example #5
Source File: CleanUpPreferenceUtil.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static Map<String, String> loadSaveParticipantOptions(IScopeContext context) { IEclipsePreferences node; if (hasSettingsInScope(context)) { node= context.getNode(JavaUI.ID_PLUGIN); } else { IScopeContext instanceScope= InstanceScope.INSTANCE; if (hasSettingsInScope(instanceScope)) { node= instanceScope.getNode(JavaUI.ID_PLUGIN); } else { return JavaPlugin.getDefault().getCleanUpRegistry().getDefaultOptions(CleanUpConstants.DEFAULT_SAVE_ACTION_OPTIONS).getMap(); } } Map<String, String> result= new HashMap<String, String>(); Set<String> keys= JavaPlugin.getDefault().getCleanUpRegistry().getDefaultOptions(CleanUpConstants.DEFAULT_SAVE_ACTION_OPTIONS).getKeys(); for (Iterator<String> iterator= keys.iterator(); iterator.hasNext();) { String key= iterator.next(); result.put(key, node.get(SAVE_PARTICIPANT_KEY_PREFIX + key, CleanUpOptions.FALSE)); } return result; }
Example #6
Source File: AdvancedQuickAssistProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static boolean getRemoveExtraParenthesesProposals(IInvocationContext context, ASTNode covering, ArrayList<ASTNode> coveredNodes, Collection<ICommandAccess> resultingCollections) { ArrayList<ASTNode> nodes; if (context.getSelectionLength() == 0 && covering instanceof ParenthesizedExpression) { nodes= new ArrayList<ASTNode>(); nodes.add(covering); } else { nodes= coveredNodes; } if (nodes.isEmpty()) return false; IProposableFix fix= ExpressionsFix.createRemoveUnnecessaryParenthesisFix(context.getASTRoot(), nodes.toArray(new ASTNode[nodes.size()])); if (fix == null) return false; if (resultingCollections == null) return true; Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_REMOVE); Map<String, String> options= new Hashtable<String, String>(); options.put(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES, CleanUpOptions.TRUE); options.put(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_NEVER, CleanUpOptions.TRUE); FixCorrectionProposal proposal= new FixCorrectionProposal(fix, new ExpressionsCleanUp(options), IProposalRelevance.REMOVE_EXTRA_PARENTHESES, image, context); resultingCollections.add(proposal); return true; }
Example #7
Source File: CleanUpSaveParticipantPreferenceConfiguration.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private String getSelectedCleanUpsText(CleanUpOptions options) { StringBuffer buf= new StringBuffer(); final ICleanUp[] cleanUps= JavaPlugin.getDefault().getCleanUpRegistry().createCleanUps(); for (int i= 0; i < cleanUps.length; i++) { cleanUps[i].setOptions(options); String[] descriptions= cleanUps[i].getStepDescriptions(); if (descriptions != null) { for (int j= 0; j < descriptions.length; j++) { if (buf.length() > 0) { buf.append('\n'); } buf.append(descriptions[j]); } } } String string= buf.toString(); return string; }
Example #8
Source File: AdvancedQuickAssistProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static boolean getAddParanoidalParenthesesProposals(IInvocationContext context, ArrayList<ASTNode> coveredNodes, Collection<ICommandAccess> resultingCollections) { IProposableFix fix= ExpressionsFix.createAddParanoidalParenthesisFix(context.getASTRoot(), coveredNodes.toArray(new ASTNode[coveredNodes.size()])); if (fix == null) return false; if (resultingCollections == null) return true; // add correction proposal Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CAST); Map<String, String> options= new Hashtable<String, String>(); options.put(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES, CleanUpOptions.TRUE); options.put(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_ALWAYS, CleanUpOptions.TRUE); FixCorrectionProposal proposal= new FixCorrectionProposal(fix, new ExpressionsCleanUp(options), IProposalRelevance.ADD_PARANOIDAL_PARENTHESES, image, context); resultingCollections.add(proposal); return true; }
Example #9
Source File: QuickAssistProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static boolean getRemoveBlockProposals(IInvocationContext context, ASTNode coveringNode, Collection<ICommandAccess> resultingCollections) { IProposableFix[] fixes= ControlStatementsFix.createRemoveBlockFix(context.getASTRoot(), coveringNode); if (fixes != null) { if (resultingCollections == null) { return true; } Map<String, String> options= new Hashtable<String, String>(); options.put(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS, CleanUpOptions.TRUE); options.put(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NEVER, CleanUpOptions.TRUE); ICleanUp cleanUp= new ControlStatementsCleanUp(options); for (int i= 0; i < fixes.length; i++) { IProposableFix fix= fixes[i]; Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); FixCorrectionProposal proposal= new FixCorrectionProposal(fix, cleanUp, IProposalRelevance.REMOVE_BLOCK_FIX, image, context); resultingCollections.add(proposal); } return true; } return false; }
Example #10
Source File: UnusedCodeFix.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static Map<String, String> getCleanUpOptions(IBinding binding, boolean removeAll) { Map<String, String> result= new Hashtable<String, String>(); result.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS, CleanUpOptions.TRUE); switch (binding.getKind()) { case IBinding.TYPE: result.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_TYPES, CleanUpOptions.TRUE); break; case IBinding.METHOD: if (((IMethodBinding) binding).isConstructor()) { result.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_CONSTRUCTORS, CleanUpOptions.TRUE); } else { result.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_METHODS, CleanUpOptions.TRUE); } break; case IBinding.VARIABLE: if (removeAll) return null; result.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_FELDS, CleanUpOptions.TRUE); result.put(CleanUpConstants.REMOVE_UNUSED_CODE_LOCAL_VARIABLES, CleanUpOptions.TRUE); break; } return result; }
Example #11
Source File: QuickAssistProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static boolean getConvertForLoopProposal(IInvocationContext context, ASTNode node, Collection<ICommandAccess> resultingCollections) { ForStatement forStatement= getEnclosingForStatementHeader(node); if (forStatement == null) return false; if (resultingCollections == null) return true; IProposableFix fix= ConvertLoopFix.createConvertForLoopToEnhancedFix(context.getASTRoot(), forStatement); if (fix == null) return false; Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); Map<String, String> options= new HashMap<String, String>(); options.put(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED, CleanUpOptions.TRUE); ICleanUp cleanUp= new ConvertLoopCleanUp(options); FixCorrectionProposal proposal= new FixCorrectionProposal(fix, cleanUp, IProposalRelevance.CONVERT_FOR_LOOP_TO_ENHANCED, image, context); proposal.setCommandId(CONVERT_FOR_LOOP_ID); resultingCollections.add(proposal); return true; }
Example #12
Source File: ContributedCleanUpTabPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public void setWorkingValues(Map<String, String> workingValues) { super.setWorkingValues(workingValues); final CleanUpOptions options= new CleanUpOptions(workingValues) { /* * @see org.eclipse.jdt.internal.ui.fix.CleanUpOptions#setOption(java.lang.String, java.lang.String) */ @Override public void setOption(String key, String value) { super.setOption(key, value); doUpdatePreview(); notifyValuesModified(); } }; SafeRunner.run(new ISafeRunnable() { public void handleException(Throwable exception) { ContributedCleanUpTabPage.this.handleException(exception); } public void run() throws Exception { fContribution.setOptions(options); } }); }
Example #13
Source File: SerialVersionSubProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static ICleanUp createCleanUp(boolean isDefault) { Map<String, String> options= new Hashtable<String, String>(); options.put(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID, CleanUpOptions.TRUE); if (isDefault) { options.put(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_DEFAULT, CleanUpOptions.TRUE); } else { options.put(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_GENERATED, CleanUpOptions.TRUE); } return new PotentialProgrammingProblemsCleanUp(options); }
Example #14
Source File: CodeFormatingTabPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected JavaPreview doCreateJavaPreview(Composite parent) { fPreview= (CleanUpPreview)super.doCreateJavaPreview(parent); fPreview.showInvisibleCharacters(true); fPreview.setFormat(CleanUpOptions.TRUE.equals(fValues.get(CleanUpConstants.FORMAT_SOURCE_CODE))); fPreview.setCorrectIndentation(CleanUpOptions.TRUE.equals(fValues.get(CleanUpConstants.FORMAT_CORRECT_INDENTATION))); return fPreview; }
Example #15
Source File: ModifierCorrectionSubProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static void addOverrideAnnotationProposal(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) { IProposableFix fix= Java50Fix.createAddOverrideAnnotationFix(context.getASTRoot(), problem); if (fix != null) { Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); Map<String, String> options= new Hashtable<String, String>(); options.put(CleanUpConstants.ADD_MISSING_ANNOTATIONS, CleanUpOptions.TRUE); options.put(CleanUpConstants.ADD_MISSING_ANNOTATIONS_OVERRIDE, CleanUpOptions.TRUE); options.put(CleanUpConstants.ADD_MISSING_ANNOTATIONS_OVERRIDE_FOR_INTERFACE_METHOD_IMPLEMENTATION, CleanUpOptions.TRUE); FixCorrectionProposal proposal= new FixCorrectionProposal(fix, new Java50CleanUp(options), IProposalRelevance.ADD_OVERRIDE_ANNOTATION, image, context); proposals.add(proposal); } }
Example #16
Source File: LocalCorrectionsSubProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static void addRemoveRedundantTypeArgumentsProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) { IProposableFix fix= TypeParametersFix.createRemoveRedundantTypeArgumentsFix(context.getASTRoot(), problem); if (fix != null) { Image image= JavaPlugin.getDefault().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE); Map<String, String> options= new HashMap<String, String>(); options.put(CleanUpConstants.USE_TYPE_ARGUMENTS, CleanUpOptions.TRUE); options.put(CleanUpConstants.REMOVE_REDUNDANT_TYPE_ARGUMENTS, CleanUpOptions.TRUE); FixCorrectionProposal proposal= new FixCorrectionProposal(fix, new TypeParametersCleanUp(options), IProposalRelevance.REMOVE_REDUNDANT_TYPE_ARGUMENTS, image, context); proposals.add(proposal); } }
Example #17
Source File: LocalCorrectionsSubProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static void addUnqualifiedFieldAccessProposal(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) { IProposableFix fix= CodeStyleFix.createAddFieldQualifierFix(context.getASTRoot(), problem); if (fix != null) { Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); Map<String, String> options= new HashMap<String, String>(); options.put(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS, CleanUpOptions.TRUE); options.put(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_ALWAYS, CleanUpOptions.TRUE); FixCorrectionProposal proposal= new FixCorrectionProposal(fix, new CodeStyleCleanUp(options), IProposalRelevance.ADD_FIELD_QUALIFIER, image, context); proposal.setCommandId(ADD_FIELD_QUALIFICATION_ID); proposals.add(proposal); } }
Example #18
Source File: ModifierCorrectionSubProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static void addDeprecatedAnnotationProposal(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) { IProposableFix fix= Java50Fix.createAddDeprectatedAnnotation(context.getASTRoot(), problem); if (fix != null) { Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); Map<String, String> options= new Hashtable<String, String>(); options.put(CleanUpConstants.ADD_MISSING_ANNOTATIONS, CleanUpOptions.TRUE); options.put(CleanUpConstants.ADD_MISSING_ANNOTATIONS_DEPRECATED, CleanUpOptions.TRUE); FixCorrectionProposal proposal= new FixCorrectionProposal(fix, new Java50CleanUp(options), IProposalRelevance.ADD_DEPRECATED_ANNOTATION, image, context); proposals.add(proposal); } }
Example #19
Source File: CleanUpConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected void configurePreview(Composite composite, int numColumns, final ProfileManager profileManager) { Map<String, String> settings= profileManager.getSelected().getSettings(); final Map<String, String> sharedSettings= new Hashtable<String, String>(); fill(settings, sharedSettings); final ICleanUp[] cleanUps= JavaPlugin.getDefault().getCleanUpRegistry().createCleanUps(); CleanUpOptions options= new MapCleanUpOptions(sharedSettings); for (int i= 0; i < cleanUps.length; i++) { cleanUps[i].setOptions(options); } createLabel(composite, CleanUpMessages.CleanUpConfigurationBlock_SelectedCleanUps_label, numColumns); final BulletListBlock cleanUpListBlock= new BulletListBlock(composite, SWT.NONE); GridData gridData= new GridData(SWT.FILL, SWT.FILL, true, true); gridData.horizontalSpan= numColumns; cleanUpListBlock.setLayoutData(gridData); cleanUpListBlock.setText(getSelectedCleanUpsInfo(cleanUps)); profileManager.addObserver(new Observer() { public void update(Observable o, Object arg) { final int value= ((Integer)arg).intValue(); switch (value) { case ProfileManager.PROFILE_CREATED_EVENT: case ProfileManager.PROFILE_DELETED_EVENT: case ProfileManager.SELECTION_CHANGED_EVENT: case ProfileManager.SETTINGS_CHANGED_EVENT: fill(profileManager.getSelected().getSettings(), sharedSettings); cleanUpListBlock.setText(getSelectedCleanUpsInfo(cleanUps)); } } }); }
Example #20
Source File: CleanUpSaveParticipantPreferenceConfiguration.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void settingsChanged() { fFormatCodeButton.setSelection(CleanUpOptions.TRUE.equals(fSettings.get(CleanUpConstants.FORMAT_SOURCE_CODE))); boolean isFormatting= fFormatCodeButton.getSelection(); fFormatChangedOnlyButton.setSelection(CleanUpOptions.TRUE.equals(fSettings.get(CleanUpConstants.FORMAT_SOURCE_CODE_CHANGES_ONLY))); fFormatAllButton.setSelection(CleanUpOptions.FALSE.equals(fSettings.get(CleanUpConstants.FORMAT_SOURCE_CODE_CHANGES_ONLY))); fFormatChangedOnlyButton.setEnabled(isFormatting); fFormatAllButton.setEnabled(isFormatting); fFormatConfigLink.setEnabled(isFormatting); fOrganizeImportsButton.setSelection(CleanUpOptions.TRUE.equals(fSettings.get(CleanUpConstants.ORGANIZE_IMPORTS))); fOrganizeImportsConfigLink.setEnabled(fOrganizeImportsButton.getSelection()); fAdditionalActionButton.setSelection(CleanUpOptions.TRUE.equals(fSettings.get(CleanUpConstants.CLEANUP_ON_SAVE_ADDITIONAL_OPTIONS))); boolean additionalEnabled= CleanUpOptions.TRUE.equals(fSettings.get(CleanUpConstants.CLEANUP_ON_SAVE_ADDITIONAL_OPTIONS)); fSelectedActionsText.setEnabled(additionalEnabled); fConfigureButton.setEnabled(additionalEnabled); Map<String, String> settings= new HashMap<String, String>(fSettings); settings.put(CleanUpConstants.FORMAT_SOURCE_CODE, CleanUpOptions.FALSE); settings.put(CleanUpConstants.ORGANIZE_IMPORTS, CleanUpOptions.FALSE); CleanUpOptions options= new MapCleanUpOptions(settings); fSelectedActionsText.setText(getSelectedCleanUpsText(options)); }
Example #21
Source File: CleanUpSaveParticipantPreferenceConfiguration.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void changeSettingsValue(String key, boolean enabled) { String value; if (enabled) { value= CleanUpOptions.TRUE; } else { value= CleanUpOptions.FALSE; } fSettings.put(key, value); settingsChanged(); }
Example #22
Source File: MapCleanUpOptions.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * @param options the options to add to this options */ public void addAll(CleanUpOptions options) { if (options instanceof MapCleanUpOptions) { fOptions.putAll(((MapCleanUpOptions)options).getMap()); } else { Set<String> keys= options.getKeys(); for (Iterator<String> iterator= keys.iterator(); iterator.hasNext();) { String key= iterator.next(); fOptions.put(key, options.getValue(key)); } } }
Example #23
Source File: CopyrightTabPage.java From saneclipse with Eclipse Public License 1.0 | 5 votes |
public Composite createContents(Composite parent) { Composite result= new Composite(parent, SWT.NONE); result.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); GridLayout layout= new GridLayout(1, false); layout.marginHeight= 0; layout.marginWidth= 0; result.setLayout(layout); Group group= new Group(result, SWT.NONE); group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); group.setLayout(new GridLayout(1, false)); group.setText(CopyrightUpdateMessages.CopyrightTabPage_groupName); final Button updateCheckbox= new Button(group, SWT.CHECK); updateCheckbox.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); updateCheckbox.setText(CopyrightUpdateMessages.CopyrightTabPage_checkboxText); updateCheckbox.setSelection(fOptions.isEnabled(CopyrightUpdaterCleanUp.UPDATE_IBM_COPYRIGHT_TO_CURRENT_YEAR)); updateCheckbox.addSelectionListener(new SelectionAdapter() { /* * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ public void widgetSelected(SelectionEvent e) { fOptions.setOption(CopyrightUpdaterCleanUp.UPDATE_IBM_COPYRIGHT_TO_CURRENT_YEAR, updateCheckbox.getSelection() ? CleanUpOptions.TRUE : CleanUpOptions.FALSE); } }); return result; }
Example #24
Source File: LocalCorrectionsSubProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static void getUnnecessaryNLSTagProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) throws CoreException { IProposableFix fix= StringFix.createFix(context.getASTRoot(), problem, true, false); if (fix != null) { Image image= JavaPlugin.getDefault().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE); Map<String, String> options= new Hashtable<String, String>(); options.put(CleanUpConstants.REMOVE_UNNECESSARY_NLS_TAGS, CleanUpOptions.TRUE); FixCorrectionProposal proposal= new FixCorrectionProposal(fix, new StringCleanUp(options), IProposalRelevance.UNNECESSARY_NLS_TAG, image, context); proposal.setCommandId(REMOVE_UNNECESSARY_NLS_TAG_ID); proposals.add(proposal); } }
Example #25
Source File: CopyrightUpdaterCleanUp.java From hybris-commerce-eclipse-plugin with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void setOptions(final CleanUpOptions options) { Assert.isLegal(options != null); Assert.isTrue(this.options == null); this.options = options; }
Example #26
Source File: CleanUpPostSaveListener.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static ICleanUp[] getCleanUps(IProject project) throws CoreException { ICleanUp[] cleanUps; Map<String, String> settings= CleanUpPreferenceUtil.loadSaveParticipantOptions(new ProjectScope(project)); if (settings == null) { IEclipsePreferences contextNode= InstanceScope.INSTANCE.getNode(JavaUI.ID_PLUGIN); String id= contextNode.get(CleanUpConstants.CLEANUP_ON_SAVE_PROFILE, null); if (id == null) { id= DefaultScope.INSTANCE.getNode(JavaUI.ID_PLUGIN).get(CleanUpConstants.CLEANUP_ON_SAVE_PROFILE, CleanUpConstants.DEFAULT_SAVE_PARTICIPANT_PROFILE); } throw new CoreException(new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, Messages.format(FixMessages.CleanUpPostSaveListener_unknown_profile_error_message, id))); } if (CleanUpOptions.TRUE.equals(settings.get(CleanUpConstants.CLEANUP_ON_SAVE_ADDITIONAL_OPTIONS))) { cleanUps= getCleanUps(settings, null); } else { HashMap<String, String> filteredSettins= new HashMap<String, String>(); filteredSettins.put(CleanUpConstants.FORMAT_SOURCE_CODE, settings.get(CleanUpConstants.FORMAT_SOURCE_CODE)); filteredSettins.put(CleanUpConstants.FORMAT_SOURCE_CODE_CHANGES_ONLY, settings.get(CleanUpConstants.FORMAT_SOURCE_CODE_CHANGES_ONLY)); filteredSettins.put(CleanUpConstants.ORGANIZE_IMPORTS, settings.get(CleanUpConstants.ORGANIZE_IMPORTS)); Set<String> ids= new HashSet<String>(2); ids.add("org.eclipse.jdt.ui.cleanup.format"); //$NON-NLS-1$ ids.add("org.eclipse.jdt.ui.cleanup.imports"); //$NON-NLS-1$ cleanUps= getCleanUps(filteredSettins, ids); } return cleanUps; }
Example #27
Source File: CleanUpPreferenceUtil.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static Map<String, String> loadFromProject(IScopeContext context) { final Map<String, String> profileOptions= new HashMap<String, String>(); IEclipsePreferences uiPrefs= context.getNode(JavaUI.ID_PLUGIN); CleanUpProfileVersioner versioner= new CleanUpProfileVersioner(); CleanUpOptions defaultOptions= JavaPlugin.getDefault().getCleanUpRegistry().getDefaultOptions(CleanUpConstants.DEFAULT_CLEAN_UP_OPTIONS); KeySet[] keySets= CleanUpProfileManager.KEY_SETS; boolean hasValues= false; for (int i= 0; i < keySets.length; i++) { KeySet keySet= keySets[i]; IEclipsePreferences preferences= context.getNode(keySet.getNodeName()); for (final Iterator<String> keyIter = keySet.getKeys().iterator(); keyIter.hasNext(); ) { final String key= keyIter.next(); String val= preferences.get(key, null); if (val != null) { hasValues= true; } else { val= defaultOptions.getValue(key); } profileOptions.put(key, val); } } if (!hasValues) return null; int version= uiPrefs.getInt(CleanUpConstants.CLEANUP_SETTINGS_VERSION_KEY, versioner.getFirstVersion()); if (version == versioner.getCurrentVersion()) return profileOptions; CustomProfile profile= new CustomProfile("tmp", profileOptions, version, versioner.getProfileKind()); //$NON-NLS-1$ versioner.update(profile); return profile.getSettings(); }
Example #28
Source File: CleanUpRegistry.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns the default options for the specified clean up kind. * * @param kind the kind of clean up for which to retrieve the options * @return the default options * * @see CleanUpConstants#DEFAULT_CLEAN_UP_OPTIONS * @see CleanUpConstants#DEFAULT_SAVE_ACTION_OPTIONS */ public MapCleanUpOptions getDefaultOptions(int kind) { ensureCleanUpInitializersRegistered(); CleanUpOptions options= new CleanUpOptions(); for (int i= 0; i < fCleanUpInitializerDescriptors.length; i++) { CleanUpInitializerDescriptor descriptor= fCleanUpInitializerDescriptors[i]; if (descriptor.getKind() == kind) { descriptor.getOptionsInitializer().setDefaultOptions(options); } } MapCleanUpOptions mapCleanUpOptions= new MapCleanUpOptions(); mapCleanUpOptions.addAll(options); return mapCleanUpOptions; }
Example #29
Source File: UnusedCodeFix.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static UnusedCodeFix createRemoveUnusedImportFix(CompilationUnit compilationUnit, IProblemLocation problem) { if (isUnusedImport(problem)) { ImportDeclaration node= getImportDeclaration(problem, compilationUnit); if (node != null) { String label= FixMessages.UnusedCodeFix_RemoveImport_description; RemoveImportOperation operation= new RemoveImportOperation(node); Map<String, String> options= new Hashtable<String, String>(); options.put(CleanUpConstants.REMOVE_UNUSED_CODE_IMPORTS, CleanUpOptions.TRUE); return new UnusedCodeFix(label, compilationUnit, new CompilationUnitRewriteOperation[] {operation}, options); } } return null; }
Example #30
Source File: CleanUpRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private RefactoringStatus setOptionsFromProfile(IJavaProject javaProject, ICleanUp[] cleanUps) { Map<String, String> options= CleanUpPreferenceUtil.loadOptions(new ProjectScope(javaProject.getProject())); if (options == null) return RefactoringStatus.createFatalErrorStatus(Messages.format(FixMessages.CleanUpRefactoring_could_not_retrive_profile, BasicElementLabels.getResourceName(javaProject.getProject()))); CleanUpOptions cleanUpOptions= new MapCleanUpOptions(options); for (int i= 0; i < cleanUps.length; i++) cleanUps[i].setOptions(cleanUpOptions); return new RefactoringStatus(); }