Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'xlc/org.eclipse.cdt.core.lrparser.xlc/ui/org/eclipse/cdt/internal')
-rw-r--r--xlc/org.eclipse.cdt.core.lrparser.xlc/ui/org/eclipse/cdt/internal/core/lrparser/xlc/ui/preferences/PreferenceMessages.java32
-rw-r--r--xlc/org.eclipse.cdt.core.lrparser.xlc/ui/org/eclipse/cdt/internal/core/lrparser/xlc/ui/preferences/PreferenceMessages.properties4
-rw-r--r--xlc/org.eclipse.cdt.core.lrparser.xlc/ui/org/eclipse/cdt/internal/core/lrparser/xlc/ui/preferences/XlcLanguageOptionsPreferencePage.java130
3 files changed, 166 insertions, 0 deletions
diff --git a/xlc/org.eclipse.cdt.core.lrparser.xlc/ui/org/eclipse/cdt/internal/core/lrparser/xlc/ui/preferences/PreferenceMessages.java b/xlc/org.eclipse.cdt.core.lrparser.xlc/ui/org/eclipse/cdt/internal/core/lrparser/xlc/ui/preferences/PreferenceMessages.java
new file mode 100644
index 00000000000..79d1b7741cb
--- /dev/null
+++ b/xlc/org.eclipse.cdt.core.lrparser.xlc/ui/org/eclipse/cdt/internal/core/lrparser/xlc/ui/preferences/PreferenceMessages.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.lrparser.xlc.ui.preferences;
+
+import org.eclipse.osgi.util.NLS;
+
+public class PreferenceMessages extends NLS {
+
+ private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.core.lrparser.xlc.ui.preferences.PreferenceMessages"; //$NON-NLS-1$
+
+ private PreferenceMessages() {}
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, PreferenceMessages.class);
+ }
+
+
+ public static String
+ XlcLanguageOptionsPreferencePage_link,
+ XlcLanguageOptionsPreferencePage_group,
+ XlcLanguageOptionsPreferencePage_preference_vectors;
+
+}
+
diff --git a/xlc/org.eclipse.cdt.core.lrparser.xlc/ui/org/eclipse/cdt/internal/core/lrparser/xlc/ui/preferences/PreferenceMessages.properties b/xlc/org.eclipse.cdt.core.lrparser.xlc/ui/org/eclipse/cdt/internal/core/lrparser/xlc/ui/preferences/PreferenceMessages.properties
new file mode 100644
index 00000000000..efad63b2024
--- /dev/null
+++ b/xlc/org.eclipse.cdt.core.lrparser.xlc/ui/org/eclipse/cdt/internal/core/lrparser/xlc/ui/preferences/PreferenceMessages.properties
@@ -0,0 +1,4 @@
+
+XlcLanguageOptionsPreferencePage_link=These settings are project-specific. The settings listed here override <a href="org.eclipse.cdt.core.lrparser.xlc.ui.XlcLanguagePreferencePage">workspace-wide</a> language settings.
+XlcLanguageOptionsPreferencePage_group=Support For XL C/C++ Language Extensions
+XlcLanguageOptionsPreferencePage_preference_vectors=Support vector types \ No newline at end of file
diff --git a/xlc/org.eclipse.cdt.core.lrparser.xlc/ui/org/eclipse/cdt/internal/core/lrparser/xlc/ui/preferences/XlcLanguageOptionsPreferencePage.java b/xlc/org.eclipse.cdt.core.lrparser.xlc/ui/org/eclipse/cdt/internal/core/lrparser/xlc/ui/preferences/XlcLanguageOptionsPreferencePage.java
new file mode 100644
index 00000000000..7bed893e08e
--- /dev/null
+++ b/xlc/org.eclipse.cdt.core.lrparser.xlc/ui/org/eclipse/cdt/internal/core/lrparser/xlc/ui/preferences/XlcLanguageOptionsPreferencePage.java
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.lrparser.xlc.ui.preferences;
+
+
+
+import org.eclipse.cdt.core.lrparser.xlc.preferences.XlcLanguagePreferences;
+import org.eclipse.cdt.core.lrparser.xlc.preferences.XlcPreferenceKeys;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.IWorkbenchPropertyPage;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+
+/**
+ * TODO trigger reindex?
+ *
+ */
+public class XlcLanguageOptionsPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, IWorkbenchPropertyPage {
+
+ private IAdaptable element;
+
+ private Button button_vectors;
+
+
+ public IAdaptable getElement() {
+ return element;
+ }
+
+ public void setElement(IAdaptable element) {
+ this.element = element;
+ }
+
+ public boolean isPropertyPage() {
+ return element != null;
+ }
+
+ public void init(IWorkbench workbench) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ Composite page = ControlFactory.createComposite(parent, 1);
+
+ if(isPropertyPage()) {
+ Link link = new Link(page, SWT.NONE);
+ link.setText(PreferenceMessages.XlcLanguageOptionsPreferencePage_link);
+ link.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ PreferencesUtil.createPreferenceDialogOn(getShell(), event.text, null, null).open();
+ }
+ });
+ }
+
+ Composite group = ControlFactory.createGroup(page, PreferenceMessages.XlcLanguageOptionsPreferencePage_group, 1);
+
+ button_vectors = ControlFactory.createCheckBox(group, PreferenceMessages.XlcLanguageOptionsPreferencePage_preference_vectors);
+ initCheckbox(button_vectors, XlcPreferenceKeys.KEY_SUPPORT_VECTOR_TYPES);
+
+ return page;
+ }
+
+
+ private void initCheckbox(Button checkbox, String prefKey) {
+ String preference = null;
+
+ if(isPropertyPage()) {
+ IProject project = getProject();
+ preference = XlcLanguagePreferences.getProjectPreference(prefKey, project);
+ }
+ else {
+ preference = XlcLanguagePreferences.getWorkspacePreference(prefKey);
+ }
+
+ if(preference == null) {
+ preference = XlcLanguagePreferences.getDefaultPreference(prefKey);
+ }
+
+ checkbox.setSelection(Boolean.valueOf(preference));
+ }
+
+
+
+ @Override
+ protected void performDefaults() {
+ button_vectors.setSelection(Boolean.valueOf(XlcLanguagePreferences.getDefaultPreference(XlcPreferenceKeys.KEY_SUPPORT_VECTOR_TYPES)));
+
+ super.performDefaults();
+ }
+
+ @Override
+ public boolean performOk() {
+ setPreference(XlcPreferenceKeys.KEY_SUPPORT_VECTOR_TYPES, button_vectors.getSelection(), getProject());
+ return true;
+ }
+
+
+ private IProject getProject() {
+ return isPropertyPage() ? (IProject)element.getAdapter(IProject.class) : null;
+ }
+
+ private static void setPreference(String key, boolean val, IProject project) {
+ if(project != null)
+ XlcLanguagePreferences.setProjectPreference(key, String.valueOf(val), project);
+ else
+ XlcLanguagePreferences.setWorkspacePreference(key, String.valueOf(val));
+ }
+
+
+}

Back to the top