diff options
Diffstat (limited to 'jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal')
18 files changed, 0 insertions, 1977 deletions
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/AllPropertySectionDescriptor.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/AllPropertySectionDescriptor.java deleted file mode 100644 index 8c5de9b4f..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/AllPropertySectionDescriptor.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.properties.internal; - -import org.eclipse.jst.pagedesigner.properties.AllPropertySection; -import org.eclipse.ui.views.properties.tabbed.AbstractSectionDescriptor; -import org.eclipse.ui.views.properties.tabbed.ISection; - -/** - * SectionDescriptor for the WPE Attributes tab - */ -public class AllPropertySectionDescriptor extends AbstractSectionDescriptor { - /** - * Id for the WPE AllPropertySectionDescriptor - */ - public static final String ID = "AllPropertySectionDescriptor"; //$NON-NLS-1$ - - private ISection section; - - public String getId() { - return ID; - } - - public ISection getSectionClass() { - if (section == null){ - section = new AllPropertySection(); - } - return section; - } - - public String getTargetTab() { - return AttributesTabDescriptor.TAB_ID; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/AttributeGroup.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/AttributeGroup.java deleted file mode 100644 index 585cd4efc..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/AttributeGroup.java +++ /dev/null @@ -1,441 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Sybase, Inc. 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: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.properties.internal; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.query.TaglibDomainMetaDataQueryHelper; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogFieldGroup; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldApplyListener; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldChangeListener; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.ISupportTextValue; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory; -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext; -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContextFactory; -import org.eclipse.jst.jsf.metadataprocessors.MetaDataEnabledProcessingFactory; -import org.eclipse.jst.pagedesigner.editors.HTMLEditor; -import org.eclipse.jst.pagedesigner.editors.properties.IPropertyPageDescriptor; -import org.eclipse.jst.pagedesigner.properties.attrgroup.IElementContextable; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; - -/** - * @author mengbo - * @version 1.5 - * - * TODO: cleanup up constructors - */ -public class AttributeGroup extends DialogFieldGroup { - private static final Object KEY_ATTR = "KEY_ATTR"; //$NON-NLS-1$ - -// private String _helpContextId; - - private List<DialogField> _dialogFields = null; //consider using Map - private IDOMElement _ownerElement; - private Entity _tagEntity; - private List<String> _attrNames; - private List<IPropertyPageDescriptor> _attrPDs; - private IStructuredDocumentContext _sdContext; - - private String _uri; - private String _tagName; - - /** - * Constructor - * @param tagEntity - may not be null - * @param attrNames - may not be null. Attribute names must be valid for the tag, and have attribute-value-runtime-type trait info - */ - public AttributeGroup(Entity tagEntity, List<String> attrNames) { - _tagEntity = tagEntity; - _attrNames = attrNames; - } - - /** - * Constructor where tagEntity is determined later or set later - * @param uri - may be null - * @param tagName - may be null - * @param attributeNames - may not be null. Attribute names must be valid for the tag, and have attribute-value-runtime-type trait info - */ - public AttributeGroup(String uri, - String tagName, String[] attributeNames) { - _uri = uri; - _tagName = tagName; - if (attributeNames != null) - _attrNames = Arrays.asList(attributeNames); - else - _attrNames = new ArrayList(); - } - - private List<IPropertyPageDescriptor> prepareDescriptors(Entity tagEntity, - List<String> names) { - - List pds = new ArrayList(); - for (String attrName : names) { - IPropertyPageDescriptor pd = getPD(tagEntity, attrName); - if (pd != null) - pds.add(pd); - } - return pds; - } - - private IPropertyPageDescriptor getPD(Entity tagEntity, String attrName) { - IPropertyPageDescriptor pd = null; - Entity attrEntity = TaglibDomainMetaDataQueryHelper.getEntity(tagEntity, attrName); - if (attrEntity != null){ - List pds = MetaDataEnabledProcessingFactory.getInstance().getAttributeValueRuntimeTypeFeatureProcessors( - IPropertyPageDescriptor.class, getStructuredDocumentContext(), attrEntity); - if (pds != null && !pds.isEmpty()) - pd = (IPropertyPageDescriptor)pds.get(0); - else - pd = new DefaultPropertyPageDescriptor(tagEntity, attrEntity); - } - return pd; - } - - - private void resetStructuredDocumentContext() { - _sdContext = null; - getStructuredDocumentContext(); - } - - private IStructuredDocumentContext getStructuredDocumentContext() { - if (_sdContext == null) { - if (_ownerElement != null) { - _sdContext = IStructuredDocumentContextFactory.INSTANCE.getContext(_ownerElement.getStructuredDocument(), _ownerElement); - - } else { - IEditorPart edPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); - if (edPart != null && edPart instanceof HTMLEditor) {//edPart will always be the WPE, but checking just to be safe - _sdContext = IStructuredDocumentContextFactory.INSTANCE.getContext(((HTMLEditor)edPart).getDocument(), 0); - } - } - } - return _sdContext; - } - - /** - * @return tag entity for this attribute group - */ - protected Entity getTagEntity() { - if (_tagEntity == null) { - if (_ownerElement != null){ - IStructuredDocumentContext context = IStructuredDocumentContextFactory.INSTANCE.getContext(_ownerElement.getStructuredDocument(), 0); - if (context != null){ - String uri = _uri != null ? _uri : IStructuredDocumentContextResolverFactory.INSTANCE.getDOMContextResolver(context).getNode().getBaseURI(); - String tagName = _tagName != null ? _tagName : IStructuredDocumentContextResolverFactory.INSTANCE.getDOMContextResolver(context).getNode().getNodeName(); - if (uri != null){ - IProject project = IStructuredDocumentContextResolverFactory.INSTANCE.getWorkspaceContextResolver(context).getProject(); - _tagEntity = TaglibDomainMetaDataQueryHelper.getEntity(TaglibDomainMetaDataQueryHelper.createMetaDataModelContext(project, uri), tagName); - } - } - } - } - return _tagEntity; - } - /** - * @return tag name - */ - public String getTagName() { - if (getTagEntity() == null) - return _tagName; - return getTagEntity().getId(); - } - - /** - * @return tag URI - */ - public String getURI() { - if (getTagEntity() == null) - return _uri; - return getTagEntity().getModel().getCurrentModelContext().getUri(); - } - - - /** - * Empty implementation. Subclasses should override to override default dialogField creation - * @param ppd - * @return DialogField - */ - protected DialogField createDialogField(IPropertyPageDescriptor ppd) { - return null; - } - -// protected DialogField createDialogField(String uri, String tag, -// String attr) { -// -// return null; -// } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogFieldGroup#initialize() - */ - public void initialize() { - if (_dialogFields == null) { - _dialogFields = new ArrayList(); - - for (IPropertyPageDescriptor pd : getAttributePDs()) { - DialogField field; - field = createDialogField(pd); - - if (field == null) { - field = pd.getDialogFieldEditor(); - } - - field.putAttachedData(KEY_ATTR, pd);//descriptors[i]); - - IDialogFieldApplyListener applyListener = getDialogFieldApplyListener(pd); -// getURI(), getTagName(), pd.getAttributeName());//descriptors[i]); - if (applyListener == null) { - applyListener = getDefaultApplyListener(); - } - field.setDialogFieldApplyListener(applyListener); - - IDialogFieldChangeListener changeListener = getDialogFieldChangeListener(pd); -// getURI(), getTagName(), pd.getAttributeName());//descriptors[i]); - if (changeListener == null) { - changeListener = getDefaultChangeListener(); - } - field.setDialogFieldChangeListener(changeListener); - _dialogFields.add(field); - } - } - } - - private List<IPropertyPageDescriptor> getAttributePDs() { - if (_attrPDs == null){ - _attrPDs = prepareDescriptors(getTagEntity(), _attrNames); - } - return _attrPDs; - } - - /** - * Child class can override the method to provide listener implementation - * - * @param ppd - * @return IDialogFieldApplyListener - */ - protected IDialogFieldApplyListener getDialogFieldApplyListener(IPropertyPageDescriptor ppd) { - return null; - } - - /** - * Child class can override the method to provide listener implementation - * - * @param ppd - * @return IDialogFieldChangeListener - */ - protected IDialogFieldChangeListener getDialogFieldChangeListener(IPropertyPageDescriptor ppd){ - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogFieldGroup#refreshData() - */ - public void refreshData() { - if (_ownerElement == null) { - return; - } - initialize(); - for (int i = 0, size = _dialogFields.size(); i < size; i++) { - DialogField field = _dialogFields.get(i); - - ISupportTextValue textValue = (ISupportTextValue) field; - IPropertyPageDescriptor attr = (IPropertyPageDescriptor) field - .getAttachedData(KEY_ATTR); - String attrName = attr.getAttributeName(); - String attrValue = _ownerElement.getAttribute(attrName); - textValue.setTextWithoutUpdate(attrValue); - } - } - - /** - * @return IDOMElement - */ - public IDOMElement getElement() { - return _ownerElement; - } - - /** - * Sets the context in each of the dialogFields in the Group - * @param context - * @param owner - */ - public void setElementContext(IDOMNode context, IDOMElement owner) { - this._ownerElement = owner; - resetStructuredDocumentContext(); - initialize(); - if (context != null) { - for (int i = 0, size = _dialogFields.size(); i < size; i++) { - DialogField field = _dialogFields.get(i); - if (field instanceof IElementContextable) { - ((IElementContextable) field).setElementContext(context, - owner); - } - } - } - refreshData(); - } - - public void layoutDialogFields(FormToolkit toolkit, Composite parent) { - Composite top; - if (toolkit == null) {//when being displayed by DialogFieldGroupPage (wizard) - top = new Composite(parent, SWT.NONE); - FillLayout fillLayout = new FillLayout(SWT.VERTICAL); - parent.setLayout(fillLayout); - } else { - top = toolkit.createComposite(parent, SWT.NONE); - } -// FillLayout fillLayout = new FillLayout(SWT.VERTICAL); -// parent.setLayout(fillLayout); - -// if (this._helpContextId != null && this._helpContextId.length() > 0) { -// PlatformUI.getWorkbench().getHelpSystem().setHelp(top, -// _helpContextId); -// } - - GridLayout layout = new GridLayout(); - int numColumns = getNumColumns(); - layout.numColumns = numColumns; - top.setLayout(layout); -// top.setLayoutData(new RowData()); - - initialize(); - for (int i = 0, size = _dialogFields.size(); i < size; i++) { - DialogField field = _dialogFields.get(i); - field.doFillIntoGrid(toolkit, top, numColumns); - } - - DialogField maxColumnField = null; - int maxColumn = 0; - for (int i = 0, size = _dialogFields.size(); i < size; i++) { - DialogField field = _dialogFields.get(i); - int c = field.getNumberOfControls(); - if (c > maxColumn) { - maxColumn = c; - maxColumnField = field; - } - } - if (maxColumnField != null) { - maxColumnField.handleGrabHorizontal(); - } - } - - /** - * @return number of columns in for composite grid layout - */ - public int getNumColumns() { - int columns = 1; - initialize(); - for (int i = 0, size = _dialogFields.size(); i < size; i++) { - DialogField field = _dialogFields.get(i); - columns = Math.max(columns, field.getNumberOfControls()); - } - return columns; - } - - @Override - public IStatus[] validateDialogFields() { - return null; - } - - /** - * @return DialogField[] - */ - public DialogField[] getDialogFields() { - initialize(); - DialogField[] ret = new DialogField[_dialogFields.size()]; - _dialogFields.toArray(ret); - return ret; - } - - /** - * get the dialogfield for the corresponding attribute. - * - * @param attrName - * case sensitive attribute name. - * @return null if fail to find. - */ - public DialogField getDialogField(String attrName) { - initialize(); - for (int i = 0, size = _dialogFields.size(); i < size; i++) { - DialogField field = _dialogFields.get(i); - IPropertyPageDescriptor attr = this.getPropertyDescriptor(field); - if (attr != null && attr.getAttributeName().equals(attrName)) { - return field; - } - } - return null; - } - - /** - * @param field - * @return IPropertyPageDescriptor - */ - public IPropertyPageDescriptor getPropertyDescriptor(DialogField field) { - Object obj = field.getAttachedData(KEY_ATTR); - if (obj instanceof IPropertyPageDescriptor) { - return (IPropertyPageDescriptor) obj; - } - return null; - } - - @Override - public void reset(){ - if (_dialogFields != null){ - for (DialogField field : _dialogFields){ - field.setDialogFieldApplyListener(null); - field.setDialogFieldChangeListener(null); - } - _dialogFields = null; - } - } - - /** - * Set the tag entity - * @param tagEntity - */ - /*package*/ void setTagEntity(Entity tagEntity) { - _tagEntity = tagEntity; - } - - public String toString(){ - StringBuffer buf = new StringBuffer("AttributeGroup: uri="); //$NON-NLS-1$ - buf.append("\r\r").append(getURI()).append("\r\rtag=").append(getTagName()); //$NON-NLS-1$ //$NON-NLS-2$ - buf.append("\r\rAttrs: "); //$NON-NLS-1$ - for (int i=0;i<_attrNames.size();i++) { - String attr = _attrNames.get(i); - buf.append(attr); - if (i<_attrNames.size()) - buf.append(", "); //$NON-NLS-1$ - } - return buf.toString(); - } - - -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/AttributeGroupSection.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/AttributeGroupSection.java deleted file mode 100644 index 49a49e421..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/AttributeGroupSection.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Sybase, Inc. 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: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.properties.internal; - -import java.util.List; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldApplyListener; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.ISupportTextValue; -import org.eclipse.jst.pagedesigner.commands.single.ChangeAttributeCommand; -import org.eclipse.jst.pagedesigner.editors.properties.IPropertyPageDescriptor; -import org.eclipse.jst.pagedesigner.properties.BaseCustomSection; -import org.eclipse.jst.pagedesigner.properties.attrgroup.AttributeGroupMessages; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; -import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory; -import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; - -/** - * This is a section for a list of attribute dialog fields. - * - * @author mengbo - * @version 1.5 - */ -public class AttributeGroupSection extends BaseCustomSection { - private static final Object KEY_ATTR = "KEY_ATTR"; //$NON-NLS-1$ - private IDialogFieldApplyListener _fieldApplyListener = new IDialogFieldApplyListener() { - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldApplyListener#dialogFieldApplied(org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField) - */ - public void dialogFieldApplied(DialogField field) { - Object attr = field.getAttachedData(KEY_ATTR); - if (attr instanceof IPropertyPageDescriptor && _element != null) { - ISupportTextValue textValue = (ISupportTextValue) field; - ChangeAttributeCommand c = new ChangeAttributeCommand( - AttributeGroupMessages - .getString("AttributeGroupSection.changeAttribute"), _element, ((IPropertyPageDescriptor) attr).getAttributeName(), textValue.getText()); //$NON-NLS-1$ - c.execute(); - } - } - }; - - private AttributeGroup _group; - - /** - * Constructor. Create the section with a default AttributeGroup. In default - * AttributeGroup, there is no relationship between fields. - * - * @param tagEntity - * @param attrNames - */ - public AttributeGroupSection(Entity tagEntity, List<String> attrNames) { - this(new AttributeGroup(tagEntity, attrNames)); - } - - /** - * Constructor. In case the group is not a default group (e.g. you may add some - * customized relationship between the fields). - * - * @param group - */ - public AttributeGroupSection(AttributeGroup group) { - _group = group; - _group.setDefaultApplyListener(_fieldApplyListener); -// _group.initialize(); - } - - public void setInput(IWorkbenchPart part, ISelection selection) { - super.setInput(part, selection); - _group.setElementContext(_element, _element); - } - - public void createControls(Composite parent, - TabbedPropertySheetPage aTabbedPropertySheetPage) { - super.createControls(parent, aTabbedPropertySheetPage); - TabbedPropertySheetWidgetFactory factory = aTabbedPropertySheetPage - .getWidgetFactory(); - _group.layoutDialogFields(factory, parent); - } - - protected void notifyChanged(INodeNotifier notifier, int eventType, - Object changedFeature, Object oldValue, Object newValue, int pos) { - if (_group != null) { - _group.refreshData(); - } - } - - @Override - public void dispose() { - super.dispose(); - _group.reset(); - } - - /** - * NOT API - for JUnit testing only - * @return @link{AttributeGroup} - */ - public AttributeGroup getAttributeGroup() { - return _group; - } -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/AttributesTabDescriptor.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/AttributesTabDescriptor.java deleted file mode 100644 index 4c0044011..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/AttributesTabDescriptor.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.properties.internal; - -import java.util.List; -import java.util.Vector; - -import org.eclipse.ui.views.properties.tabbed.AbstractTabDescriptor; -import org.eclipse.ui.views.properties.tabbed.ISectionDescriptor; - -/** - * Attributes tab descriptor - * - */ -public class AttributesTabDescriptor extends AbstractTabDescriptor { - - /** - * Attributes tab id - */ - public static final String TAB_ID = "jst.pagedesigner.tabbed.properties.attributes"; //$NON-NLS-1$ - - private Vector<ISectionDescriptor> descriptors; - - /** - * Constructor - */ - public AttributesTabDescriptor(){ - super(); - descriptors = new Vector<ISectionDescriptor>(1); - descriptors.add(new AllPropertySectionDescriptor()); - } - - @Override - public List getSectionDescriptors() { - return descriptors; - } - - public String getCategory() { - return "attributes"; //$NON-NLS-1$ - } - - public String getId() { - return TAB_ID; - } - - public String getLabel() { - return Messages.AttributesTabDescriptor_label; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/DefaultPropertyPageDescriptor.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/DefaultPropertyPageDescriptor.java deleted file mode 100644 index e32213cf4..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/DefaultPropertyPageDescriptor.java +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.properties.internal; - -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory; -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext; -import org.eclipse.jst.jsf.metadataprocessors.MetaDataContext; -import org.eclipse.jst.pagedesigner.editors.properties.IPropertyPageDescriptor; -import org.eclipse.jst.pagedesigner.meta.EditorCreator; -import org.eclipse.jst.pagedesigner.meta.IAttributeRuntimeValueType; -import org.eclipse.jst.pagedesigner.meta.internal.CellEditorFactoryRegistry; -import org.eclipse.jst.pagedesigner.properties.ITabbedPropertiesConstants; -import org.eclipse.swt.widgets.Composite; -import org.w3c.dom.Element; - -/** - * Property descriptor implementation for when meta data is available, but the - * meta data type is not adaptable to a {@link IPropertyPageDescriptor}. - * - * It is assumed that the value type is - * {@link org.eclipse.jst.jsf.taglibprocessing.attributevalues.StringType}. - */ -public class DefaultPropertyPageDescriptor implements IPropertyPageDescriptor -{ - private Entity _tagEntity; - private Entity _attrEntity; - - private IStructuredDocumentContext _sdContext; - private MetaDataContext _mdContext; - - /** - * Constructor - * - * @param tagEntity - * @param attrEntity - */ - public DefaultPropertyPageDescriptor(Entity tagEntity, Entity attrEntity) - { - _tagEntity = tagEntity; - _attrEntity = attrEntity; - } - - public String getAttributeName() - { - return _attrEntity.getId(); - } - - public String getCategory() - { - return ITabbedPropertiesConstants.OTHER_CATEGORY; - } - - public CellEditor getCellEditor(Composite parent) - { - Element element = (Element) IStructuredDocumentContextResolverFactory.INSTANCE - .getDOMContextResolver(getStructuredDocumentContext()) - .getNode(); - return CellEditorFactoryRegistry.getInstance().createCellEditor(parent, - this, element); - } - - public String getDescription() - { - return null; - } - - public DialogField getDialogFieldEditor() - { - EditorCreator creator = EditorCreator.getInstance(); - return creator.createDialogFieldWithWrapper(getUri(), getTagName(), - this, null); - } - - public String getLabel() - { - return getAttributeName() + ":"; //$NON-NLS-1$ - } - - public String getTagName() - { - return _tagEntity.getId(); - } - - public String getUri() - { - return _tagEntity.getModel().getCurrentModelContext().getUri(); - } - - public String getValueType() - { - return IAttributeRuntimeValueType.STRING; - } - - public boolean isRequired() - { - return false; - } - - public MetaDataContext getMetaDataContext() - { - return _mdContext; - } - - public IStructuredDocumentContext getStructuredDocumentContext() - { - return _sdContext; - } - - public void setMetaDataContext(MetaDataContext context) - { - _mdContext = context; - } - - public void setStructuredDocumentContext(IStructuredDocumentContext context) - { - _sdContext = context; - } - - public Object getAdapter(Class adapter) - { - return null; - } - - public String toString() - { - return getUri() - + "/" + getTagName() + "/" + getAttributeName() + " (Default Descriptor)"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/MDQuickEditTabSectionDescriptor.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/MDQuickEditTabSectionDescriptor.java deleted file mode 100644 index e1628d438..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/MDQuickEditTabSectionDescriptor.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.properties.internal; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.views.properties.tabbed.AbstractSectionDescriptor; -import org.eclipse.ui.views.properties.tabbed.ISection; - -/** - * Quick Edit section descriptor that uses the quickEditSection trait meta data for the tag entity of the selection - * to determine the sections to display - * - */ -public class MDQuickEditTabSectionDescriptor extends AbstractSectionDescriptor { - - /** - * Default constructor - */ - public MDQuickEditTabSectionDescriptor() { - super(); - } - - @Override - public boolean appliesTo(IWorkbenchPart part, ISelection selection) { - return true;// we will always display tab, but will show text that no quick edit properties are available when they aren't - } - - public ISection getSectionClass() { - return new QuickEditTabSection(); - } - - public String getTargetTab() { - return QuickEditTabDescriptor.TAB_ID; - } - - public String getId() { - return "mdQuickEditTabSections"; //$NON-NLS-1$ - } - -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/Messages.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/Messages.java deleted file mode 100644 index 275a500b8..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/Messages.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.properties.internal; - -import org.eclipse.osgi.util.NLS; - -/** - * Externalized strings - * - */ -public class Messages extends NLS { - private static final String BUNDLE_NAME = "org.eclipse.jst.pagedesigner.properties.internal.messages"; //$NON-NLS-1$ - /** - * - */ - public static String AttributesTabDescriptor_label; - /** - * - */ - public static String QuickEditTabDescriptor_label; - static { - // initialize resource bundle - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } - - private Messages() { - // - } -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/NullQuickEditTabGroupDescriptor.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/NullQuickEditTabGroupDescriptor.java deleted file mode 100644 index 893b6ab42..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/NullQuickEditTabGroupDescriptor.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.properties.internal; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.ui.views.properties.tabbed.ISection; - -/** - * QuickEdit Tab section when quick edit section info is not available. - * - * Ideally we should not be displaying the tab in the absence of MD, but due to current - * issues with the tabbed-properties framework, it is easier to simply display a "null" - * section. - * - */ -public class NullQuickEditTabGroupDescriptor extends - QuickEditTabSectionsDescriptor { - - private List<ISection> nullQuickEditSection; - - /** - * Constructor - */ - public NullQuickEditTabGroupDescriptor() { - super(); - } - - @Override - public List<ISection> getSections() { - return nullQuickEditSection; - } - - @Override - public void calculateSections() { - nullQuickEditSection = new ArrayList<ISection>(1); - nullQuickEditSection.add(new NullQuickEditTabSection()); - } - - -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/NullQuickEditTabSection.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/NullQuickEditTabSection.java deleted file mode 100644 index 11712bf68..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/NullQuickEditTabSection.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.properties.internal; - -import org.eclipse.jst.pagedesigner.PDPlugin; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection; -import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; -import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory; - -/** - * Section that displays text that no quick edit properties are available for the input - */ -public class NullQuickEditTabSection extends AbstractPropertySection { - - @Override - public void createControls(Composite parent, - TabbedPropertySheetPage tabbedPropertySheetPage) { - super.createControls(parent, tabbedPropertySheetPage); - TabbedPropertySheetWidgetFactory factory = tabbedPropertySheetPage.getWidgetFactory(); - - Composite cont = factory.createComposite(parent, SWT.NO_FOCUS); - GridLayout layout = new GridLayout(1, false); - cont.setLayout(layout); - - CLabel lbl = - factory.createCLabel(cont, PDPlugin.getResourceString("QuickEditTab.no_quick_edit_md"));//$NON-NLS-1$ - lbl.setLayoutData(new GridData()); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/QuickEditTabDescriptor.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/QuickEditTabDescriptor.java deleted file mode 100644 index 591706507..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/QuickEditTabDescriptor.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.properties.internal; - -import org.eclipse.ui.views.properties.tabbed.AbstractTabDescriptor; - -/** - * Quick Edit Tab Descriptor - */ -public class QuickEditTabDescriptor extends AbstractTabDescriptor { - - /** - * Quick Edit tab id - */ - public static final String TAB_ID = "jst.pagedesigner.tabbed.properties.quickedit"; //$NON-NLS-1$ - - /** - * Constructor - */ - public QuickEditTabDescriptor(){ - super(); - getSectionDescriptors().add(new MDQuickEditTabSectionDescriptor()); - } - - public String getCategory() { - return "quickedit"; //$NON-NLS-1$ - } - - public String getId() { - return TAB_ID; - } - - public String getLabel() { - return Messages.QuickEditTabDescriptor_label; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/QuickEditTabManager.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/QuickEditTabManager.java deleted file mode 100644 index 55de9cb3a..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/QuickEditTabManager.java +++ /dev/null @@ -1,217 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.properties.internal; - -import javax.xml.namespace.QName; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.query.ITaglibDomainMetaDataModelContext; -import org.eclipse.jst.jsf.common.metadata.query.TaglibDomainMetaDataQueryHelper; -import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory; -import org.eclipse.jst.jsf.context.resolver.structureddocument.ITaglibContextResolver; -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext; -import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContextFactory; -import org.eclipse.jst.pagedesigner.editors.HTMLEditor; -import org.eclipse.jst.pagedesigner.editors.properties.quickedittabsections.QuickEditTabSections; -import org.eclipse.jst.pagedesigner.properties.DesignerPropertyTool; -import org.eclipse.jst.pagedesigner.properties.WPETabbedPropertySheetPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.part.FileEditorInput; -import org.w3c.dom.Element; - -/** - * One-to-one with {@link WPETabbedPropertySheetPage} that manages the current sections for the current selection. - * <p> - * The QuickEditTabManager has a shared instance of a {@link QuickEditTabSectionsManager} for the project. - * <p> - * When a WPETabbedPropertySheetPage is created, it must acquire a QuickEditTabManager using the static acquireInstance method, - * and then release the instance when it is disposed. This ensures that the QuickEditTabSectionsManager shared instance (per project) is released appropriately. - * <p> - * selectionChanged method must be called prior to calling createControls on the sections for this tab group call. - */ -public class QuickEditTabManager { - private QuickEditTabSectionsManager _groupsManager; - private QuickEditTabSections _quickEditTabSections; - private Entity _tagEntity; - private QName _lastTagID; - private QuickEditTabSectionsDescriptor _lastQuickEditTabGroup; - private QuickEditTabSectionsDescriptor _nullQuickEditTabGroup; - private Element _lastElement; - - private QuickEditTabSectionsManager getRegistry() { - return _groupsManager; - } - - /** - * Must only be called once per tabbed property sheet as ref count is kept. - * Callers must call releaseInstance when the page is disposed - * @param page - * @return instance for this property sheet - */ - public static synchronized QuickEditTabManager acquireInstance(WPETabbedPropertySheetPage page) { - IProject project = getProject(page); - QuickEditTabManager instance = new QuickEditTabManager(); - instance._groupsManager = QuickEditTabSectionsManager.acquireInstance(project); - return instance; - } - - /** - * Releases this instance, but does not dispose. Ensures that the {@link QuickEditTabSectionsManager} is released. - */ - public synchronized void releaseInstance() { - this._groupsManager.releaseInstance(); - } - - /** - * Private constructor - */ - private QuickEditTabManager(){ - // - } - - private static IProject getProject(WPETabbedPropertySheetPage page) { - IProject proj = null; - IDocument doc = ((HTMLEditor)page.getEditor()).getDocument(); - IStructuredDocumentContext context = IStructuredDocumentContextFactory.INSTANCE.getContext(doc, 0); - if (context != null){ - proj = IStructuredDocumentContextResolverFactory.INSTANCE.getWorkspaceContextResolver(context).getProject(); - } - return proj; - - } - /** - * Must be called so that the sections for the input can be calculated. - * - * @param part - * @param selection - * @return true if current selection is different than during the last call - */ - public boolean selectionChanged(IWorkbenchPart part, ISelection selection) { - boolean hasChanged = false; - QuickEditTabSections qets = getQuickTabSectionsMetaData(part, selection); - if (qets == null) {//use null quick edit tab - hasChanged = (_quickEditTabSections != null); - _quickEditTabSections = qets; - _lastQuickEditTabGroup = getNullQuickEditTab(); - _lastTagID = null; - } - else { - QName tagId = getTagId(); - if (_lastTagID == null || !_lastTagID.equals(tagId)){ - _quickEditTabSections = qets; - QuickEditTabSectionsDescriptor group = getRegistry().getQuickEditTabSectionsFor(tagId); - if (group == null){ - group = createQuickEditTabGroup(tagId, _quickEditTabSections); - if (group != null){ - group.calculateSections(); - getRegistry().addQuickEditTabGroupDescriptor(group); - } - } - _lastQuickEditTabGroup = group; - _lastTagID = tagId; - } - } - - return hasChanged; - } - - /** - * @return current QuickEditTabSectionsDescriptor - */ - public QuickEditTabSectionsDescriptor getCurrentTabGroupDescriptor() { - return _lastQuickEditTabGroup; - } - - private QuickEditTabSections getQuickTabSectionsMetaData(IWorkbenchPart part, - ISelection selection) { - - Element node = DesignerPropertyTool.getElement(part, selection); - if (node == null) { - return null; - } - if (_lastElement != node){ - _lastElement = node; - _quickEditTabSections = null; - _tagEntity = getTagEntity(part, selection, node); - if (_tagEntity != null) { - Trait pds = TaglibDomainMetaDataQueryHelper.getTrait(_tagEntity, QuickEditTabSections.TRAIT_ID); - if (pds != null){ - _quickEditTabSections = (QuickEditTabSections)pds.getValue(); - } - } - } - return _quickEditTabSections; - } - - private QuickEditTabSectionsDescriptor createQuickEditTabGroup(QName tagId, - QuickEditTabSections tabSections) { - return new QuickEditTabSectionsDescriptor(_tagEntity, tagId, tabSections); - } - - private QName getTagId() { - return TaglibDomainMetaDataQueryHelper.getQNameForTagEntity(_tagEntity); - } - - /** - * Dispose - */ - public void dispose() { - _lastQuickEditTabGroup= null; - _lastElement = null; - _lastTagID = null; - _nullQuickEditTabGroup = null; - _quickEditTabSections = null; - _groupsManager = null; - } - - private Entity getTagEntity(IWorkbenchPart part, ISelection selection, Element node){ - HTMLEditor ed = null; - if (part instanceof HTMLEditor) - ed = (HTMLEditor)part; - if (ed == null) - return null; - - if (ed.getEditorInput() instanceof FileEditorInput) { - FileEditorInput input = (FileEditorInput)ed.getEditorInput(); - IStructuredDocumentContext context = IStructuredDocumentContextFactory.INSTANCE.getContext(ed.getDocument(), node); - if (context != null){ - ITaglibContextResolver resolver = IStructuredDocumentContextResolverFactory.INSTANCE.getTaglibContextResolver(context); - if (resolver != null){ - ITaglibDomainMetaDataModelContext mdContext = TaglibDomainMetaDataQueryHelper.createMetaDataModelContext(input.getFile().getProject(),resolver.getTagURIForNodeName(node)); - return TaglibDomainMetaDataQueryHelper.getEntity(mdContext, node.getLocalName()); - } - } - } - return null; - } - - private QuickEditTabSectionsDescriptor getNullQuickEditTab() { - if (_nullQuickEditTabGroup == null) { - _nullQuickEditTabGroup = new NullQuickEditTabGroupDescriptor(); - _nullQuickEditTabGroup.calculateSections(); - } - return _nullQuickEditTabGroup; - } - - /** - * NOT API - for JUnit testing only - * @return {@link QuickEditTabSectionsManager} - */ - public QuickEditTabSectionsManager getQuickEditTabSectionsManager() { - return _groupsManager; - } - - -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/QuickEditTabSection.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/QuickEditTabSection.java deleted file mode 100644 index 172626c30..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/QuickEditTabSection.java +++ /dev/null @@ -1,209 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.properties.internal; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jst.pagedesigner.properties.WPETabbedPropertySheetPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Layout; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection; -import org.eclipse.ui.views.properties.tabbed.ISection; -import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; - -/** - * Using the tag entity's QuickEditTabSections meta-data, this section reacts to changes in selection, - * and will dynamically create a QuickEditTabGroup. The QuickEditTabGroup is cached and reused. - * <br><br> - * This section delegates construction to the sections discovered thru meta data. - * Because this section is not disposed of until the tab is disposed, this section will enforce the expected section lifecycle - * on the sections loaded from meta data. This occurs during setInput. But will pass on all section lifecycle events as - * this section receives them. - * <br><br> - * The lifecycle that this section enforces on it's child sections in the setInput call on this section are (in order): - * <li>createControls - * <li>setInput - * <li>aboutToBeShown - * <li>refresh - * - * When tab section lifecycle events occur to this section, they are passed on to all child sections also. - * - */ -public class QuickEditTabSection extends AbstractPropertySection { - - private QuickEditTabManager manager; - private Composite _composite; - private Composite _qeGroupComposite; - private WPETabbedPropertySheetPage _tabbedPropertySheetPage; - - private QuickEditTabManager getTabManager() { - if (manager == null) { - manager = _tabbedPropertySheetPage.getTabManager(); - } - return manager; - } - - @Override - public void createControls(Composite parent, - TabbedPropertySheetPage tabbedPropertySheetPage) { - super.createControls(parent, tabbedPropertySheetPage); - _composite = parent; - _tabbedPropertySheetPage = (WPETabbedPropertySheetPage)tabbedPropertySheetPage; - } - - @Override - public void setInput(IWorkbenchPart part, ISelection selection) { - super.setInput(part, selection); - if (getTabManager() != null){ - aboutToBeHidden(); - createOrResetQuickEditGroupComposite();//disposes of old and recreates new topComp - getTabManager().selectionChanged(part, selection); - for (ISection section : getSections()){ - section.createControls(_qeGroupComposite, _tabbedPropertySheetPage); - section.setInput(part, selection); - } - _composite.getParent().layout(true, true); - - aboutToBeShown(); - refresh(); - } - } - - @Override - public void aboutToBeHidden() { - super.aboutToBeHidden(); - for (ISection section : getSections()){ - section.aboutToBeHidden(); - } - } - - @Override - public void aboutToBeShown() { - super.aboutToBeShown(); - for (ISection section : getSections()){ - section.aboutToBeShown(); - } - } - - @Override - public void refresh() { - super.refresh(); - for (ISection section : getSections()){ - section.refresh(); - } - } - - private void createOrResetQuickEditGroupComposite() { - if (_qeGroupComposite != null && !_qeGroupComposite.isDisposed()){ - //dispose of current sections - disposeCurrentQuickEditTabSections(); - _qeGroupComposite.dispose(); - } - - _qeGroupComposite = _tabbedPropertySheetPage.getWidgetFactory().createComposite(_composite, SWT.NO_FOCUS); - QuickEditTabLayout layout = new QuickEditTabLayout(); - _qeGroupComposite.setLayout(layout); - - } - - private void disposeCurrentQuickEditTabSections() { - for (ISection section : getSections()){ - section.dispose(); - } - } - - private List<ISection> getSections(){ - if (getTabManager().getCurrentTabGroupDescriptor() != null) - return getTabManager().getCurrentTabGroupDescriptor().getSections(); - - return Collections.EMPTY_LIST; - } - - public void dispose() { - super.dispose(); - disposeCurrentQuickEditTabSections(); - manager.dispose(); - manager = null; - _composite = null; - _qeGroupComposite = null; - _tabbedPropertySheetPage = null; - } - - public boolean shouldUseExtraSpace() { - return false; - } - - private class QuickEditTabLayout extends Layout { - - // allow for adjustments - private static final int MARGIN = 0; - private static final int SPACING = 0; - - // cache - Point[] sizes; - int maxWidth, totalHeight; - - protected Point computeSize(Composite composite, int wHint, int hHint, - boolean flushCache) { - - Control children[] = composite.getChildren(); - if (flushCache || sizes == null || sizes.length != children.length) { - initialize(children); - } - - int width = wHint, height = hHint; - if (wHint == SWT.DEFAULT) - width = maxWidth; - - if (hHint == SWT.DEFAULT) - height = totalHeight; - - return new Point(width + 2 * MARGIN, height + 2 * MARGIN); - } - - protected void layout(Composite composite, boolean flushCache) { - Control children[] = composite.getChildren(); - if (flushCache || sizes == null || sizes.length != children.length) { - initialize(children); - } - Rectangle rect = composite.getClientArea(); - int x = MARGIN, y = MARGIN; - int width = Math.max(rect.width - 2 * MARGIN, maxWidth); -// System.out.println("--- Comp id: "+composite.toString()+ "[#Children: "+ composite.getChildren().length +"] -------"); - for (int i = 0; i < children.length; i++) { - int height = sizes[i].y; - children[i].setBounds(x, y, width, height); - y += height + SPACING; -// System.out.println("h="+height+", y="+y); - } - composite.setRedraw(true); - } - - void initialize(Control children[]) { - maxWidth = 0; - totalHeight = 0; - sizes = new Point[children.length]; - for (int i = 0; i < children.length; i++) { - sizes[i] = children[i].computeSize(SWT.DEFAULT, SWT.DEFAULT, true); - maxWidth = Math.max(maxWidth, sizes[i].x); - totalHeight += sizes[i].y; - } - totalHeight += (children.length - 1) * SPACING; - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/QuickEditTabSectionDescriptor.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/QuickEditTabSectionDescriptor.java deleted file mode 100644 index 18fddd4ce..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/QuickEditTabSectionDescriptor.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Sybase, Inc. 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: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.properties.internal; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.pagedesigner.PDPlugin; -import org.eclipse.jst.pagedesigner.properties.DesignerPropertyTool; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.internal.views.properties.tabbed.view.SectionDescriptor; -import org.eclipse.ui.views.properties.tabbed.ISection; -import org.eclipse.ui.views.properties.tabbed.ITypeMapper; -import org.w3c.dom.Element; - -/** - * A SectionDescriptor from org.eclipse.ui.views.properties.tabbed.propertySections extension-point - * for use by the QuickEdit tab in the Web Page Editor. - */ -public class QuickEditTabSectionDescriptor extends SectionDescriptor { - - private static final String ATT_CLASS = "class"; //$NON-NLS-1$ - private IConfigurationElement _configurationElement; - private Entity _tagEntity; - - /** - * Constructor for the section descriptor. - * - * @param configurationElement - * the configuration element for the section descriptor. - * @param typeMapper - */ - public QuickEditTabSectionDescriptor(IConfigurationElement configurationElement, ITypeMapper typeMapper) { - super(configurationElement, typeMapper); - _configurationElement = configurationElement; - } - - @Override - public boolean appliesTo(IWorkbenchPart part, ISelection selection) { - Element node = DesignerPropertyTool.getElement(part, selection); - if (node == null) { - return false; - } - return true; - } - - @Override - public ISection getSectionClass() { - ISection section = null; - try { - Object secOrGroup = _configurationElement - .createExecutableExtension(ATT_CLASS); - if (secOrGroup instanceof ISection) { - section = (ISection) secOrGroup; - } else if (secOrGroup instanceof AttributeGroup) { - ((AttributeGroup) secOrGroup).setTagEntity(_tagEntity); - section = new AttributeGroupSection((AttributeGroup) secOrGroup); - } - } catch (CoreException exception) { - handleSectionError(exception); - } - return section; - } - - /** - * Handle the section error when an issue is found loading from the - * configuration element. - * - * @param _configurationElement - * the configuration element - * @param exception - * an optional CoreException - */ - private void handleSectionError(CoreException exception) { - PDPlugin.getLogger(QuickEditTabSectionDescriptor.class).error("error", //$NON-NLS-1$ - exception); - exception.printStackTrace(); - } - - /** - * @param tagEntity - * @return ISection for the tagEntity - */ - /*package*/ ISection getSectionClass(Entity tagEntity) { - _tagEntity = tagEntity; - return getSectionClass(); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/QuickEditTabSectionsDescriptor.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/QuickEditTabSectionsDescriptor.java deleted file mode 100644 index afba39238..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/QuickEditTabSectionsDescriptor.java +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.properties.internal; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.namespace.QName; - -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.pagedesigner.editors.properties.quickedittabsections.QuickEditTabSections; -import org.eclipse.jst.pagedesigner.editors.properties.quickedittabsections.SECTION_TYPE; -import org.eclipse.jst.pagedesigner.editors.properties.quickedittabsections.SectionInfo; -import org.eclipse.ui.views.properties.tabbed.ISection; - -/** - * Represents all of the section classes that make up the Quick Edit tab for a given tag input. - * Uses QuickEditTabSections meta data from tag entity - */ -public class QuickEditTabSectionsDescriptor { - - private QuickEditTabSections _sections; - private QName _tagId; - private List<ISection> _sectionClasses; - private Entity _tagEntity; - private WPETabPropertySectionDescriptorProvider sectionProvider; - - /** - * Constructor - * @param tagEntity - * @param tagId - * @param sections - */ - public QuickEditTabSectionsDescriptor (Entity tagEntity, QName tagId, QuickEditTabSections sections) { - _tagEntity = tagEntity; - _tagId = tagId; - _sections = sections; - } - - /*package*/ QuickEditTabSectionsDescriptor () { - _tagEntity = null; - _tagId = null; - _sections = null; - } - - /** - * Determines section classes for the group from the available meta data - */ - public void calculateSections() { - if (_sectionClasses == null || _sectionClasses.isEmpty()) { - _sectionClasses = new ArrayList(); - List<String> attrIds = new ArrayList(); - for (SectionInfo secInfo : _sections.getSections()) { - if (secInfo.getType() == SECTION_TYPE.ATTRIBUTE){ - //collect attrSecs and process as a group so that layout will be best - if (secInfo.getId() != null) - attrIds.add(secInfo.getId()); - } - else if (secInfo.getType() == SECTION_TYPE.SECTION) { - //if there are any attribute sections not processed, do that now - if (attrIds.size() > 0){ - createAttributeGroup(attrIds); - attrIds = new ArrayList(); - } - createSectionGroup(secInfo); - } - } - if (attrIds.size() > 0){ - createAttributeGroup(attrIds); - } - } - } - - private void createSectionGroup(SectionInfo secInfo) { - QuickEditTabSectionDescriptor sd = getSectionProvider().getNamedSectionDescriptor(secInfo.getId()); - if (sd != null) { - ISection section = sd.getSectionClass(_tagEntity); - if (section != null){ - _sectionClasses.add(section); - } - } - - } - - private void createAttributeGroup(List<String> attrNames) { - ISection section = new AttributeGroupSection(_tagEntity, attrNames); - if (section != null){ - _sectionClasses.add(section); - } - } - - /** - * @return QName of tag that this tab descriptor is for - */ - public QName getTagId() { - return _tagId; - } - - /** - * @return List of current ISection classes set after calculateSections() has been called - */ - public List<ISection> getSections() { - return _sectionClasses; - } - - private WPETabPropertySectionDescriptorProvider getSectionProvider() { - if (sectionProvider == null){ - sectionProvider = new WPETabPropertySectionDescriptorProvider(); - } - return sectionProvider; - } - - -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/QuickEditTabSectionsManager.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/QuickEditTabSectionsManager.java deleted file mode 100644 index 17bbc4516..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/QuickEditTabSectionsManager.java +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.properties.internal; - -import java.util.HashMap; -import java.util.Map; - -import javax.xml.namespace.QName; - -import org.eclipse.core.resources.IProject; - -/** - * Cache of quickEditTabGroupDescriptors keyed by tagID as QName. - */ -public class QuickEditTabSectionsManager { - - private static QuickEditTabSectionsManagerMgr _mgrInstance = new QuickEditTabSectionsManagerMgr(); - private Map<QName, QuickEditTabSectionsDescriptor> map = new HashMap<QName, QuickEditTabSectionsDescriptor>(5); - private IProject _project; - private int clientCount = 0; - - /** - * Returns instance of QuickEditTabSectionsManager for the given project. Caller must release the instance when caller is being disposed. - * @param project - * @return instance of QuickEditTabSectionsManager - */ - public static synchronized QuickEditTabSectionsManager acquireInstance(IProject project){ - QuickEditTabSectionsManager instance = _mgrInstance.getSectionsManager(project); - instance.clientCount++; - return instance; - } - - /** - * Releases instance of QuickEditTabSectionsManager and removes from the QuickEditSectionGroupsManagerMgr if it is the last reference - */ - public synchronized void releaseInstance(){ - int refCount = --clientCount; - if (refCount == 0){ - _mgrInstance.removeSectionsManager(_project); - } - } - - /** - * private constructor - */ - private QuickEditTabSectionsManager(){ - // - } - - /** - * @return IProject that this section manager applies to - */ - public IProject getProject(){ - return _project; - } - - /** - * Get QuickEditTabSectionsDescriptor for passed tag - * - * @param tagId - * @return QuickEditTabSectionsDescriptor - */ - public QuickEditTabSectionsDescriptor getQuickEditTabSectionsFor(QName tagId) { - return map.get(tagId); - } - - /** - * Adds QuickEditTabSectionsDescriptor to managed registry keyed by the tagId - * QName - * - * @param group - */ - public void addQuickEditTabGroupDescriptor(QuickEditTabSectionsDescriptor group) { - map.put(group.getTagId(), group); - } - - /** - * Removes and disposes a cached {@link QuickEditTabSectionsDescriptor} - * - * @param tagId - */ - public void removeQuickEditTabGroup(QName tagId) { - QuickEditTabSectionsDescriptor grp = map.get(tagId); - if (grp != null) { - map.remove(tagId); - } - } - - /** - * Manages the QuickEditTabSectionsManager instances. Ensures one per project. - */ - private static class QuickEditTabSectionsManagerMgr { - private Map <IProject,QuickEditTabSectionsManager>_map = new HashMap<IProject,QuickEditTabSectionsManager>(); - /** - * @param project - may be null - * @return QuickEditTabManager for project - */ - public QuickEditTabSectionsManager getSectionsManager(IProject project){ - if (_map.containsKey(project)) - return _map.get(project); - - QuickEditTabSectionsManager instance = new QuickEditTabSectionsManager(); - instance._project = project; - _map.put(project, instance); - return instance; - } - - /** - * Removes QuickEditTabManager from mgr for given project - * @param project - */ - public void removeSectionsManager(IProject project){ - if (_map.containsKey(project)) - _map.remove(project); - } - - } -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/WPETabDescriptorProvider.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/WPETabDescriptorProvider.java deleted file mode 100644 index 5003d40d6..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/WPETabDescriptorProvider.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.properties.internal; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.views.properties.tabbed.ITabDescriptor; -import org.eclipse.ui.views.properties.tabbed.ITabDescriptorProvider; - -/** - * Class that provides the default tabs for the Web Page Editor - */ -public class WPETabDescriptorProvider implements ITabDescriptorProvider { - - private AttributesTabDescriptor _attributesTabDescriptor; - private QuickEditTabDescriptor _quickTabDescriptor; - - /** - * Constructor - */ - public WPETabDescriptorProvider() { - _quickTabDescriptor = new QuickEditTabDescriptor(); - _attributesTabDescriptor = new AttributesTabDescriptor(); - } - - /** - * Provides a QuickTabDescriptor and the AttributesTabDescriptor - */ - public ITabDescriptor[] getTabDescriptors(IWorkbenchPart part, - ISelection selection) { - - return new ITabDescriptor[]{_quickTabDescriptor, - _attributesTabDescriptor}; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/WPETabPropertySectionDescriptorProvider.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/WPETabPropertySectionDescriptorProvider.java deleted file mode 100644 index 4e2530dcb..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/WPETabPropertySectionDescriptorProvider.java +++ /dev/null @@ -1,127 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Sybase, Inc. 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: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.pagedesigner.properties.internal; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jst.pagedesigner.editors.HTMLEditor; -import org.eclipse.ui.views.properties.tabbed.ISectionDescriptor; -import org.eclipse.ui.views.properties.tabbed.ISectionDescriptorProvider; - -/** - * Provides sections registered for the Web Page Editor whose contributor ID is, - * "org.eclipse.jst.pagedesigner.tabPropertyContributor" using the - * org.eclipse.ui.views.properties.tabbed.propertyTabs extension-points. - * - * The sections declared using the org.eclipse.ui.views.properties.tabbed.propertySections extension-point - * for the WPE will only be displayed by the Quick Edit tab is the selected tag has metadata to choose - * the section. TypeMappers/filters, etc. are ignored by this sectionDescriptorProvider. - * - * See jsf_html.xml in the org.eclipse.jst.jsf.standard.tagsupport plugin for examples on how to use. - */ -public class WPETabPropertySectionDescriptorProvider implements - ISectionDescriptorProvider { - - private static final String EXTPT_SECTIONS = "propertySections"; //$NON-NLS-1$ - private static final String ELEMENT_SECTION = "propertySection"; //$NON-NLS-1$ - private ISectionDescriptor[] _descriptors = null; - - /** - * Constructor - */ - public WPETabPropertySectionDescriptorProvider() { - super(); - } - - public ISectionDescriptor[] getSectionDescriptors() { - if (_descriptors == null) { - List result = new ArrayList(); - List contributedSections = readSectionDescriptors(); - result.addAll(contributedSections); - -// if (1 == 0){ //disabled for now... do we want to allow other mechanisms to add sections? -// List providers = readAdditionalSectionDescriptorProviders(); -// for (int i = 0, size = providers.size(); i < size; i++) { -// try { -// ISectionDescriptorProvider provider = (ISectionDescriptorProvider) providers -// .get(i); -// ISectionDescriptor[] sections = provider -// .getSectionDescriptors(); -// if (sections != null) { -// result.addAll(Arrays.asList(sections)); -// } -// } catch (Exception ex) { -// // ignore -// ex.printStackTrace(); -// } -// } -// } - _descriptors = new ISectionDescriptor[result.size()]; - result.toArray(_descriptors); - } - return _descriptors; - } - - /** - * @return registered section descriptors for the WPE QuickEdit tab - */ - protected List<QuickEditTabSectionDescriptor> readSectionDescriptors() { - List result = new ArrayList(); - - IConfigurationElement[] extensions = getConfigurationElements(EXTPT_SECTIONS); - for (int i = 0; i < extensions.length; i++) { - IConfigurationElement extension = extensions[i]; - if (extension.getAttribute("contributorId").equals(HTMLEditor.TABBED_PROPERTIES_CONTRIBUTOR_ID)){ //$NON-NLS-1$ - IConfigurationElement[] sections = extension - .getChildren(ELEMENT_SECTION); - for (int j = 0; j < sections.length; j++) { - IConfigurationElement section = sections[j]; - ISectionDescriptor descriptor = new QuickEditTabSectionDescriptor( - section, null);//ITypeMapper set to null - result.add(descriptor); - } - } - } - return result; - } - - /** - * @param extensionPointId - * @return IConfigurationElement[] - */ - private static IConfigurationElement[] getConfigurationElements( - String extensionPointId) { - IExtensionPoint extensionPoint = Platform.getExtensionRegistry() - .getExtensionPoint("org.eclipse.ui.views.properties.tabbed", extensionPointId); //$NON-NLS-1$ - if (extensionPoint == null) { - return null; - } - return extensionPoint.getConfigurationElements(); - } - - /** - * @param name of section - * @return {@link QuickEditTabSectionDescriptor} or null if not located - */ - public QuickEditTabSectionDescriptor getNamedSectionDescriptor(String name) { - for (int i=0;i<getSectionDescriptors().length;i++){ - QuickEditTabSectionDescriptor sd = (QuickEditTabSectionDescriptor)getSectionDescriptors()[i]; - if (name.equals(sd.getId())) - return sd; - } - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/messages.properties b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/messages.properties deleted file mode 100644 index 57b015f57..000000000 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/properties/internal/messages.properties +++ /dev/null @@ -1,12 +0,0 @@ -############################################################################### -# Copyright (c) 2001, 2007 Oracle 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: -# Oracle Corporation - initial API and implementation -############################################################################### -AttributesTabDescriptor_label=Attributes -QuickEditTabDescriptor_label=Quick Edit |