Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/internal/VisiblePageSingleton.java')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/internal/VisiblePageSingleton.java75
1 files changed, 75 insertions, 0 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/internal/VisiblePageSingleton.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/internal/VisiblePageSingleton.java
new file mode 100644
index 00000000000..5253a2fbe55
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/internal/VisiblePageSingleton.java
@@ -0,0 +1,75 @@
+/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ *
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.pages.internal;
+
+import org.eclipse.jface.preference.IPreferencePage;
+import org.eclipse.papyrus.preferences.pages.AbstractPapyrusPreferencePage;
+import org.eclipse.papyrus.preferences.pages.DiagramPreferencePage;
+
+/**
+ * This singleton has bee created to manage the button ok and apply of preference page.
+ * In the case of button ok pressed, the behavior of eclipse try of apply in the first preference page found.
+ * Here each page has a specific behavior. So to store the preference, the active page is called
+ *
+ */
+public class VisiblePageSingleton {
+
+ private static VisiblePageSingleton instance;
+
+ private IPreferencePage page;
+
+ /**
+ *
+ * @return the instance of the {@link VisiblePageSingleton}
+ */
+ public static VisiblePageSingleton getInstance() {
+ if(instance == null) {
+ instance = new VisiblePageSingleton();
+ }
+ return instance;
+ }
+
+ /**
+ * set the visible page
+ *
+ * @param page
+ * a {@link IPreferencePage} --> {@link DiagramPreferencePage} or {@link AbstractPapyrusPreferencePage}
+ */
+ public void setVisiblePage(IPreferencePage page) {
+ this.page = page;
+ }
+
+ /**
+ *
+ * @return the Visible Page
+ */
+ public IPreferencePage getVisiblePage() {
+ return this.page;
+ }
+
+ /**
+ * call the visisble page in order to store preferences
+ */
+ public void store() {
+ if(this.page != null) {
+ if(this.page instanceof DiagramPreferencePage) {
+ ((DiagramPreferencePage)(this.page)).storeAllPreferences();
+ }
+ if(this.page instanceof AbstractPapyrusPreferencePage) {
+ ((AbstractPapyrusPreferencePage)(this.page)).storeAllPreferences();
+ }
+
+ }
+ }
+}

Back to the top