FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Manage start/end symbol with project property preferences. See · codecopy/angularjs-eclipse@2476bd5 · GitHub

Commit 2476bd5

Browse files
committed
Manage start/end symbol with project property preferences. See
angelozerr#68
1 parent e35265b commit 2476bd5

13 files changed

Lines changed: 170 additions & 27 deletions

File tree

‎org.eclipse.angularjs.core.tests/META-INF/MANIFEST.MF‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
77
Require-Bundle: org.junit;bundle-version="4.11.0",
88
org.eclipse.angularjs.core;bundle-version="0.2.0",
99
org.eclipse.wst.xml.core;bundle-version="1.1.800",
10-
org.eclipse.wst.sse.core;bundle-version="1.1.800"
10+
org.eclipse.wst.sse.core;bundle-version="1.1.800",
11+
org.eclipse.core.resources;bundle-version="3.9.0"

‎org.eclipse.angularjs.core/src/org/eclipse/angularjs/core/AngularCoreConstants.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@ public class AngularCoreConstants {
2626
public static String DIRECTIVE_COLON_DELIMITER = "directiveColonDelimiter"; //$NON-NLS-1$
2727
public static final String DIRECTIVE_MINUS_DELIMITER = "directiveMinusDelimiter"; //$NON-NLS-1$
2828
public static final String DIRECTIVE_UNDERSCORE_DELIMITER = "directiveUnderscoreDelimiter"; //$NON-NLS-1$
29+
public static final String EXPRESSION_START_SYMBOL = "startSymbol"; //$NON-NLS-1$
30+
public static final String EXPRESSION_END_SYMBOL = "endSymbol"; //$NON-NLS-1$
2931
}

‎org.eclipse.angularjs.core/src/org/eclipse/angularjs/core/AngularProject.java‎

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import org.eclipse.core.runtime.Platform;
2727
import org.eclipse.core.runtime.QualifiedName;
2828
import org.eclipse.core.runtime.Status;
29+
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
30+
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
2931

3032
import tern.angular.modules.AngularModulesManager;
3133
import tern.angular.modules.Directive;
@@ -52,6 +54,8 @@ public class AngularProject implements IDirectiveSyntax {
5254
public static final String DEFAULT_END_SYMBOL = "}}";
5355

5456
private final IProject project;
57+
private String startSymbol;
58+
private String endSymbol;
5559

5660
private final Map<ITernScriptPath, List<BaseModel>> folders;
5761
private static List<String> angularNatureAdapters;
@@ -70,6 +74,35 @@ public void onStop(ITernServer server) {
7074
customDirectives.clear();
7175
}
7276
});
77+
// initialize symbols from project preferences
78+
initializeSymbols();
79+
AngularCorePreferencesSupport.getInstance()
80+
.getEclipsePreferences(project)
81+
.addPreferenceChangeListener(new IPreferenceChangeListener() {
82+
83+
@Override
84+
public void preferenceChange(PreferenceChangeEvent event) {
85+
if (AngularCoreConstants.EXPRESSION_START_SYMBOL
86+
.equals(event.getKey())) {
87+
AngularProject.this.startSymbol = event
88+
.getNewValue().toString();
89+
} else if (AngularCoreConstants.EXPRESSION_END_SYMBOL
90+
.equals(event.getKey())) {
91+
AngularProject.this.endSymbol = event.getNewValue()
92+
.toString();
93+
}
94+
}
95+
});
96+
}
97+
98+
/**
99+
* Initialize start/end symbols.
100+
*/
101+
private void initializeSymbols() {
102+
this.startSymbol = AngularCorePreferencesSupport.getInstance()
103+
.getStartSymbol(getProject());
104+
this.endSymbol = AngularCorePreferencesSupport.getInstance()
105+
.getEndSymbol(getProject());
73106
}
74107

75108
public static AngularProject getAngularProject(IProject project)
@@ -257,7 +290,7 @@ private void ensureNatureIsConfigured() throws CoreException {
257290
* @return the start symbol used inside HTML for angular expression.
258291
*/
259292
public String getStartSymbol() {
260-
return DEFAULT_START_SYMBOL;
293+
return startSymbol;
261294
}
262295

263296
/**
@@ -266,7 +299,7 @@ public String getStartSymbol() {
266299
* @return the end symbol used inside HTML for angular expression.
267300
*/
268301
public String getEndSymbol() {
269-
return DEFAULT_END_SYMBOL;
302+
return endSymbol;
270303
}
271304

272305
}

‎org.eclipse.angularjs.core/src/org/eclipse/angularjs/internal/core/preferences/AngularCorePreferenceConstants.java‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import org.eclipse.angularjs.core.AngularCoreConstants;
1414
import org.eclipse.angularjs.core.AngularCorePlugin;
15+
import org.eclipse.angularjs.core.AngularProject;
1516
import org.eclipse.core.runtime.preferences.DefaultScope;
1617
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
1718

@@ -27,8 +28,14 @@ public static void initializeDefaultValues() {
2728
IEclipsePreferences node = new DefaultScope()
2829
.getNode(AngularCorePlugin.PLUGIN_ID);
2930
// directive syntax
30-
node.putBoolean(AngularCoreConstants.DIRECTIVE_STARTS_WITH_NOTHING, true);
31+
node.putBoolean(AngularCoreConstants.DIRECTIVE_STARTS_WITH_NOTHING,
32+
true);
3133
node.putBoolean(AngularCoreConstants.DIRECTIVE_MINUS_DELIMITER, true);
34+
// start/end symbols used in angular expression
35+
node.put(AngularCoreConstants.EXPRESSION_START_SYMBOL,
36+
AngularProject.DEFAULT_START_SYMBOL);
37+
node.put(AngularCoreConstants.EXPRESSION_END_SYMBOL,
38+
AngularProject.DEFAULT_END_SYMBOL);
3239
}
3340

3441
// Don't instantiate

‎org.eclipse.angularjs.core/src/org/eclipse/angularjs/internal/core/preferences/AngularCorePreferencesSupport.java‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212

1313
import org.eclipse.angularjs.core.AngularCoreConstants;
1414
import org.eclipse.angularjs.core.AngularCorePlugin;
15+
import org.eclipse.angularjs.core.AngularProject;
1516
import org.eclipse.core.resources.IProject;
1617
import org.eclipse.core.runtime.Preferences;
18+
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
1719

1820
import tern.eclipse.ide.core.preferences.PreferencesSupport;
1921
import tern.utils.StringUtils;
@@ -75,4 +77,41 @@ public boolean getBool(IProject project, String key) {
7577
return StringUtils.asBoolean(result, false);
7678
}
7779

80+
/**
81+
* Return the {@link IEclipsePreferences} from the given project.
82+
*
83+
* @param project
84+
* @return the {@link IEclipsePreferences} from the given project.
85+
*/
86+
public IEclipsePreferences getEclipsePreferences(IProject project) {
87+
return preferencesSupport.getEclipsePreferences(project);
88+
}
89+
90+
/**
91+
* Returns the start symbol to use for angular expression inside HTML for
92+
* the given project.
93+
*
94+
* @param project
95+
* @return the start symbol to use for angular expression inside HTML for
96+
* the given project.
97+
*/
98+
public String getStartSymbol(IProject project) {
99+
return preferencesSupport.getPreferencesValue(
100+
AngularCoreConstants.EXPRESSION_START_SYMBOL,
101+
AngularProject.DEFAULT_START_SYMBOL, project);
102+
}
103+
104+
/**
105+
* Returns the end symbol to use for angular expression inside HTML for the
106+
* given project.
107+
*
108+
* @param project
109+
* @return the end symbol to use for angular expression inside HTML for the
110+
* given project.
111+
*/
112+
public String getEndSymbol(IProject project) {
113+
return preferencesSupport.getPreferencesValue(
114+
AngularCoreConstants.EXPRESSION_END_SYMBOL,
115+
AngularProject.DEFAULT_END_SYMBOL, project);
116+
}
78117
}

‎org.eclipse.angularjs.ui/plugin.properties‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ HTMLAngularTypingPreferencePage.name=Typing
2424
# Project properties
2525
AngularMainPropertyPage.name=AngularJS
2626
DirectivesPropertyPage.name=Directives
27+
ExpressionPropertyPage.name=Expression
2728

2829
# Hyperlink
2930
HTMLAngularHyperLinkDetector.name=HTML Angular HyperLink

‎org.eclipse.angularjs.ui/plugin.xml‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,18 @@
205205
<test property="org.eclipse.angularjs.ui.isAngularProject" />
206206
</adapt>
207207
</enabledWhen>
208-
</page>
208+
</page>
209+
<page
210+
name="%ExpressionPropertyPage.name"
211+
category="org.eclipse.angularjs.internal.ui.properties.AngularMainPropertyPage"
212+
class="org.eclipse.angularjs.internal.ui.properties.ExpressionPropertyPage"
213+
id="org.eclipse.angularjs.internal.ui.properties.ExpressionPropertyPage">
214+
<enabledWhen>
215+
<adapt type="org.eclipse.core.resources.IProject">
216+
<test property="org.eclipse.angularjs.ui.isAngularProject" />
217+
</adapt>
218+
</enabledWhen>
219+
</page>
209220
</extension>
210221

211222
<!-- Angular UI Adapter factories -->

‎org.eclipse.angularjs.ui/src/org/eclipse/angularjs/internal/ui/AngularUIMessages.java‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public final class AngularUIMessages extends NLS {
4747
public static String TerminateTernServerAction_tooltip;
4848
public static String UnLinkToControllerAction_text;
4949
public static String UnLinkToControllerAction_tooltip;
50-
50+
5151
public static String AngularExplorerView_openFile_error;
5252
public static String AngularExplorerView_openFileDialog_title;
5353

@@ -67,7 +67,10 @@ public final class AngularUIMessages extends NLS {
6767
public static String DirectivesPropertyPage_minusDelimiter_label;
6868
public static String DirectivesPropertyPage_underscoreDelimiter_label;
6969
public static String DirectivesPropertyPage_directiveTestLabel_text;
70-
70+
71+
public static String ExpressionPropertyPage_startSybol_label;
72+
public static String ExpressionPropertyPage_endSybol_label;
73+
7174
private AngularUIMessages() {
7275
}
7376

‎org.eclipse.angularjs.ui/src/org/eclipse/angularjs/internal/ui/AngularUIMessages.properties‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ DirectivesPropertyPage_delimiterLabel_text=Directive names must use following de
3838
DirectivesPropertyPage_colonDelimiter_label=':'
3939
DirectivesPropertyPage_minusDelimiter_label='-'
4040
DirectivesPropertyPage_underscoreDelimiter_label='_'
41-
DirectivesPropertyPage_directiveTestLabel_text=Here directive names which will available in completion for
41+
DirectivesPropertyPage_directiveTestLabel_text=Here directive names which will available in completion for
42+
ExpressionPropertyPage_startSybol_label=Start sybol:
43+
ExpressionPropertyPage_endSybol_label=End sybol:

‎org.eclipse.angularjs.ui/src/org/eclipse/angularjs/internal/ui/properties/AbstractAngularFieldEditorPropertyPage.java‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,19 @@
1010
*/
1111
package org.eclipse.angularjs.internal.ui.properties;
1212

13+
import org.eclipse.angularjs.core.AngularCorePlugin;
1314
import org.eclipse.angularjs.core.AngularProject;
15+
import org.eclipse.core.resources.IProject;
1416
import org.eclipse.core.resources.IResource;
17+
import org.eclipse.core.resources.ProjectScope;
1518
import org.eclipse.core.runtime.CoreException;
1619
import org.eclipse.core.runtime.IAdaptable;
20+
import org.eclipse.core.runtime.preferences.IScopeContext;
1721
import org.eclipse.jface.preference.FieldEditorPreferencePage;
22+
import org.eclipse.jface.preference.IPreferenceStore;
1823
import org.eclipse.jface.resource.ImageDescriptor;
1924
import org.eclipse.ui.IWorkbenchPropertyPage;
25+
import org.eclipse.ui.preferences.ScopedPreferenceStore;
2026

2127
public abstract class AbstractAngularFieldEditorPropertyPage extends
2228
FieldEditorPreferencePage implements IWorkbenchPropertyPage {
@@ -66,4 +72,15 @@ private IResource getResource() {
6672
return resource;
6773
}
6874

75+
@Override
76+
protected IPreferenceStore doGetPreferenceStore() {
77+
IProject project = null;
78+
try {
79+
project = getAngularProject().getProject();
80+
} catch (CoreException e) {
81+
}
82+
IScopeContext projectScope = new ProjectScope(project);
83+
return new ScopedPreferenceStore(projectScope,
84+
AngularCorePlugin.PLUGIN_ID);
85+
}
6986
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL