Skip to main content
summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMarc-Andre Laperle2011-07-18 02:49:09 -0400
committerMarc-Andre Laperle2011-07-18 02:49:09 -0400
commit11963d3ec565744758c2fa4ac4b8e947ee71733d (patch)
treeea830ac84e1eed4b8e47ffd5d27efd70fb8e39af /core
parent114952f64a850260f9d4043d5d31fd690d8ca99d (diff)
downloadorg.eclipse.cdt-11963d3ec565744758c2fa4ac4b8e947ee71733d.tar.gz
org.eclipse.cdt-11963d3ec565744758c2fa4ac4b8e947ee71733d.tar.xz
org.eclipse.cdt-11963d3ec565744758c2fa4ac4b8e947ee71733d.zip
Bug 352262 - Link to Name Style preference page from Generate Getters
and Setters page
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersInputPage.java44
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterContext.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterInsertEditProvider.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterNameGenerator.java24
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.properties2
6 files changed, 90 insertions, 7 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersInputPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersInputPage.java
index 52766bd1a4..5b272b2cf8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersInputPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersInputPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -14,6 +14,10 @@ package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters;
import java.util.Set;
import java.util.SortedSet;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
@@ -25,12 +29,17 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Link;
import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.preferences.NameStylePreferencePage;
import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.GetterSetterContext.FieldWrapper;
import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.GetterSetterInsertEditProvider.AccessorKind;
-public class GenerateGettersAndSettersInputPage extends UserInputWizardPage {
+public class GenerateGettersAndSettersInputPage extends UserInputWizardPage implements IPreferenceChangeListener {
private GetterSetterContext context;
private ContainerCheckedTreeViewer variableSelectionView;
private GetterSetterLabelProvider labelProvider;
@@ -38,6 +47,9 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage {
public GenerateGettersAndSettersInputPage(GetterSetterContext context) {
super(Messages.GettersAndSetters_Name);
this.context = context;
+ IEclipsePreferences node = InstanceScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID);
+ // We are listening for changes in the Name Style preferences
+ node.addPreferenceChangeListener(this);
}
public void createControl(Composite parent) {
@@ -59,6 +71,8 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage {
final Button placeImplemetation = new Button(comp, SWT.CHECK);
placeImplemetation.setText(Messages.GenerateGettersAndSettersInputPage_PlaceImplHeader);
gd = new GridData();
+ gd.horizontalSpan = 2;
+ gd.heightHint = 40;
placeImplemetation.setLayoutData(gd);
placeImplemetation.setSelection(context.isImplementationInHeader());
placeImplemetation.addSelectionListener(new SelectionAdapter() {
@@ -68,6 +82,21 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage {
}
});
+ Link link= new Link(comp, SWT.WRAP);
+ link.setText(Messages.GenerateGettersAndSettersInputPage_LinkDescription);
+ link.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ String id = NameStylePreferencePage.PREF_ID;
+ PreferencesUtil.createPreferenceDialogOn(getShell(), id, new String [] { id }, null).open();
+ }
+ });
+ link.setToolTipText(Messages.GenerateGettersAndSettersInputPage_LinkTooltip);
+
+ gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ gd.grabExcessHorizontalSpace = true;
+ link.setLayoutData(gd);
+
setControl(comp);
}
@@ -189,4 +218,15 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage {
}
});
}
+
+ public void preferenceChange(PreferenceChangeEvent event) {
+ if (variableSelectionView.getTree().isDisposed()) {
+ return;
+ }
+
+ if (GetterSetterNameGenerator.getGenerateGetterSettersPreferenceKeys().contains(event.getKey())) {
+ context.refresh();
+ variableSelectionView.refresh();
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterContext.java
index 8d70806bdf..757619cb40 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterContext.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterContext.java
@@ -78,6 +78,17 @@ public class GetterSetterContext implements ITreeContentProvider {
public Object[] getElements(Object inputElement) {
return getWrappedFields().toArray();
}
+
+ public void refresh() {
+ // We only recreate the function declarations instead of recreating GetterSetterInsertEditProviders.
+ // That way, selectedFunctions is still valid. Also, the objects inside the TreeViewer are still the same
+ // which is convenient because that way we don't need to save then restore the collapsed/expanded+checked/unchecked state of the TreeViewer.
+ for (FieldWrapper wrapper : wrappedFields) {
+ for (GetterSetterInsertEditProvider provider : wrapper.childNodes) {
+ provider.createFunctionDeclaration();
+ }
+ }
+ }
public void dispose() {
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterInsertEditProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterInsertEditProvider.java
index 7a17d6604b..05eb4e954b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterInsertEditProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterInsertEditProvider.java
@@ -36,7 +36,15 @@ public class GetterSetterInsertEditProvider implements Comparable<GetterSetterIn
public GetterSetterInsertEditProvider(IASTName fieldName, IASTSimpleDeclaration fieldDeclaration,
AccessorKind kind) {
- switch (kind) {
+ this.kind = kind;
+ this.fieldName = fieldName;
+ this.fieldDeclaration = fieldDeclaration;
+
+ createFunctionDeclaration();
+ }
+
+ public void createFunctionDeclaration() {
+ switch (this.kind) {
case GETTER:
this.functionDeclaration = FunctionFactory.createGetterDeclaration(fieldName, fieldDeclaration);
break;
@@ -44,10 +52,6 @@ public class GetterSetterInsertEditProvider implements Comparable<GetterSetterIn
this.functionDeclaration = FunctionFactory.createSetterDeclaration(fieldName, fieldDeclaration);
break;
}
-
- this.kind = kind;
- this.fieldName = fieldName;
- this.fieldDeclaration = fieldDeclaration;
}
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterNameGenerator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterNameGenerator.java
index 0b721b69ee..3574b0bff4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterNameGenerator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterNameGenerator.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters;
+import java.util.HashSet;
+import java.util.Set;
+
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.IPreferencesService;
@@ -32,7 +35,28 @@ public class GetterSetterNameGenerator {
// Do not instantiate.
private GetterSetterNameGenerator() {
}
+
+ private static Set<String> generateGetterSettersPreferenceKeys = new HashSet<String>();
+ static {
+ generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_GETTER_CAPITALIZATION);
+ generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_GETTER_WORD_DELIMITER);
+ generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_GETTER_PREFIX_FOR_BOOLEAN);
+ generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_GETTER_PREFIX);
+ generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_GETTER_SUFFIX);
+ generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_SETTER_CAPITALIZATION);
+ generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_SETTER_WORD_DELIMITER);
+ generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_SETTER_PREFIX);
+ generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_SETTER_SUFFIX);
+ generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_VARIABLE_CAPITALIZATION);
+ generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_VARIABLE_WORD_DELIMITER);
+ generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_VARIABLE_PREFIX);
+ generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_VARIABLE_SUFFIX);
+ }
+ public static Set<String> getGenerateGetterSettersPreferenceKeys() {
+ return generateGetterSettersPreferenceKeys;
+ }
+
public static String generateGetterName(IASTName fieldName) {
IPreferencesService preferences = Platform.getPreferencesService();
int capitalization = preferences.getInt(CUIPlugin.PLUGIN_ID,
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.java
index d74929b29c..8094488375 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.java
@@ -20,6 +20,8 @@ public final class Messages extends NLS {
public static String GenerateGettersAndSettersInputPage_SelectAll;
public static String GenerateGettersAndSettersInputPage_SelectGetters;
public static String GenerateGettersAndSettersInputPage_SelectSetters;
+ public static String GenerateGettersAndSettersInputPage_LinkDescription;
+ public static String GenerateGettersAndSettersInputPage_LinkTooltip;
public static String GenerateGettersAndSettersRefactoring_NoCassDefFound;
public static String GenerateGettersAndSettersRefactoring_NoFields;
public static String GenerateGettersAndSettersRefactoring_NoImplFile;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.properties
index bb018b5816..c9cf1f7cc3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.properties
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.properties
@@ -16,6 +16,8 @@ GenerateGettersAndSettersInputPage_PlaceImplHeader=Place implementation in heade
GenerateGettersAndSettersInputPage_SelectAll=Select All
GenerateGettersAndSettersInputPage_SelectGetters=Select Getters
GenerateGettersAndSettersInputPage_SelectSetters=Select Setters
+GenerateGettersAndSettersInputPage_LinkDescription=The names of getters and setters may be configured on the <a>Name Style</a> preference page.
+GenerateGettersAndSettersInputPage_LinkTooltip=Show the name style preferences.
GenerateGettersAndSettersRefactoring_NoCassDefFound=No class definition found
GenerateGettersAndSettersRefactoring_NoFields=The class does not contain any fields.
GenerateGettersAndSettersRefactoring_NoImplFile=No implementation file found. Inserting definition into the header file.

Back to the top