From f8d8620ddcc5be3800b43293dfc3e266675f5b3a Mon Sep 17 00:00:00 2001 From: Oleg Krasilnikov Date: Tue, 24 Apr 2007 09:05:44 +0000 Subject: [PATCH] Bug #183341: property page and tab in single object --- .../eclipse/cdt/ui/newui/AbstractPage.java | 6 +- .../cdt/ui/newui/AbstractSinglePage.java | 104 ++++++++++++++++++ 2 files changed, 107 insertions(+), 3 deletions(-) create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractSinglePage.java diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java index f6138caf1f6..7a2a6c344ec 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java @@ -132,7 +132,7 @@ implements /* * Bookeeping variables */ - private boolean noContentOnPage = false; + protected boolean noContentOnPage = false; protected boolean displayedConfig = false; protected IResource internalElement = null; protected boolean isProject = false; @@ -143,7 +143,7 @@ implements // tabs protected TabFolder folder; protected ArrayList itabs = new ArrayList(); - ICPropertyTab currentTab; + protected ICPropertyTab currentTab; protected class InternalTab { Composite comp; @@ -667,7 +667,7 @@ implements return out; } - private void cfgChanged(ICConfigurationDescription _cfgd) { + protected void cfgChanged(ICConfigurationDescription _cfgd) { resd = getResDesc(_cfgd); if (excludeFromBuildCheck != null) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractSinglePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractSinglePage.java new file mode 100644 index 00000000000..f43cf5727ff --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractSinglePage.java @@ -0,0 +1,104 @@ +/******************************************************************************* + * Copyright (c) 2007 Intel 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: + * Intel Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.newui; + +import org.eclipse.swt.widgets.Composite; + +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICResourceDescription; + +/** + * Bug #183341 : Single property page which does not + * require separate cPropertyTab to display data. + * + */ +public abstract class AbstractSinglePage extends AbstractPage { + + /** + * Implement this method to create your own widgets + */ + public abstract void createWidgets(Composite c); + + /** + * Implement this method to perform apply: + * copy all data affected by this page + * from src resource description to dst + * @param src + * @param dst + */ + protected abstract void performApply(ICResourceDescription src, ICResourceDescription dst); + + /** + * Rewrite this method to handle configuration change + * Do not forget to call super.cfgChanged(_cfgd); + */ + protected void cfgChanged(ICConfigurationDescription _cfgd) { + super.cfgChanged(_cfgd); + // if (displayedConfig) { + // update widgets according to getResDesc() values + // } + } + + /** + * Usually, this method needs not to be rewritten + */ + public boolean performCancel() { + // if (! noContentOnPage && displayedConfig) { + // do nothing in most cases + // } + return true; + } + + /** + * Rewrite this method to restore default + * values in current ResourceDescription + */ + public void performDefaults() { + // if (! noContentOnPage && displayedConfig) { + // do something with getResDesc() fields + // } + } + + /** + * Usually, this method needs not to be rewritten + */ + public boolean performOk() { + if (! noContentOnPage && displayedConfig) { + // do nothing in most cases + } + return super.performOk(); + } + + /** + * + */ + public void setVisible(boolean visible) { + super.setVisible(visible); + if (visible) { + cfgChanged(getResDesc().getConfiguration()); + } + } + + /** + * No need to rewrite + */ + protected boolean isSingle() { return true; } + + /** + * Call to "foreach" does not really matter, since we have not tabs + * But we intercept this call to perform other operations (apply). + */ + protected void forEach(int m, Object data) { + if (m == ICPropertyTab.APPLY) + performApply(getResDesc(), (ICResourceDescription)data); + } + +}