diff options
author | sbouchet | 2012-04-23 12:47:57 +0000 |
---|---|---|
committer | sbouchet | 2012-04-23 12:47:57 +0000 |
commit | 8b43c046e17a6beb0193a2b4ea71a58d14d295a5 (patch) | |
tree | c4ddfc758c057753d389a28a3f4ed6107211a93c /plugins | |
parent | d3e6e0a09b780862d6c5efd9603ccd332cf3e3f7 (diff) | |
download | org.eclipse.eef-8b43c046e17a6beb0193a2b4ea71a58d14d295a5.tar.gz org.eclipse.eef-8b43c046e17a6beb0193a2b4ea71a58d14d295a5.tar.xz org.eclipse.eef-8b43c046e17a6beb0193a2b4ea71a58d14d295a5.zip |
fixed global actions in details page
Diffstat (limited to 'plugins')
2 files changed, 102 insertions, 42 deletions
diff --git a/plugins/org.eclipse.emf.eef.runtime.extended/src/org/eclipse/emf/eef/runtime/ui/editors/pages/EEFDetailsPage.java b/plugins/org.eclipse.emf.eef.runtime.extended/src/org/eclipse/emf/eef/runtime/ui/editors/pages/EEFDetailsPage.java index 5cce5233f..35d676fbe 100644 --- a/plugins/org.eclipse.emf.eef.runtime.extended/src/org/eclipse/emf/eef/runtime/ui/editors/pages/EEFDetailsPage.java +++ b/plugins/org.eclipse.emf.eef.runtime.extended/src/org/eclipse/emf/eef/runtime/ui/editors/pages/EEFDetailsPage.java @@ -18,6 +18,8 @@ import org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent; import org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent; import org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionListener; import org.eclipse.emf.eef.runtime.context.impl.DomainPropertiesEditionContext; +import org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent; +import org.eclipse.emf.eef.runtime.ui.editor.InteractiveEEFEditor; import org.eclipse.emf.eef.runtime.ui.layout.EEFFormLayoutFactory; import org.eclipse.emf.eef.runtime.ui.viewers.PropertiesEditionContentProvider; import org.eclipse.emf.eef.runtime.ui.viewers.PropertiesEditionMessageManager; @@ -37,26 +39,29 @@ import org.eclipse.ui.forms.widgets.FormToolkit; /** * @author <a href="mailto:goulwen.lefur@obeo.fr">Goulwen Le Fur</a> - * */ public class EEFDetailsPage extends AbstractFormPart implements IDetailsPage, IPropertiesEditionListener { - + private FormToolkit toolkit; + private EditingDomain editingDomain; + protected EObject eObject; + protected IPropertiesEditionComponent propertiesEditionComponent; - + /** - * Manager for error message - */ + * Manager for error message + */ private PropertiesEditionMessageManager messageManager; protected PropertiesEditionViewer viewer; + private AdapterFactory adapterFactory; public EEFDetailsPage(FormToolkit toolkit, EditingDomain editingDomain, AdapterFactory adapterFactory) { super(); - this.toolkit = toolkit; + this.toolkit = toolkit; this.editingDomain = editingDomain; this.adapterFactory = adapterFactory; } @@ -82,7 +87,9 @@ public class EEFDetailsPage extends AbstractFormPart implements IDetailsPage, IP this.viewer = new PropertiesEditionViewer(container, null, SWT.NONE, 1); viewer.setDynamicTabHeader(true); viewer.setToolkit(getManagedForm().getToolkit()); - viewer.setContentProvider(new PropertiesEditionContentProvider(adapterFactory, IPropertiesEditionComponent.LIVE_MODE, editingDomain)); + viewer.setContentProvider(new PropertiesEditionContentProvider(adapterFactory, + IPropertiesEditionComponent.LIVE_MODE, editingDomain)); + viewer.addPropertiesListener(this); } public void selectionChanged(IFormPart part, ISelection selection) { @@ -95,20 +102,22 @@ public class EEFDetailsPage extends AbstractFormPart implements IDetailsPage, IP if (eObject != null) { if (viewer.getToolkit() == null) viewer.setToolkit(toolkit); - viewer.setInput(new DomainPropertiesEditionContext(null, null, editingDomain, adapterFactory, eObject)); + viewer.setInput(new DomainPropertiesEditionContext(null, null, editingDomain, adapterFactory, + eObject)); viewer.addPropertiesListener(this); } } } private EObject getEObjectFromSelection(ISelection selection) { - if (selection instanceof StructuredSelection && (((StructuredSelection)selection).getFirstElement() instanceof EObject)) - return (EObject) ((StructuredSelection)selection).getFirstElement(); + if (selection instanceof StructuredSelection + && (((StructuredSelection)selection).getFirstElement() instanceof EObject)) + return (EObject)((StructuredSelection)selection).getFirstElement(); if (selection instanceof EObject) - return (EObject) selection; + return (EObject)selection; if (selection instanceof IAdaptable && ((IAdaptable)selection).getAdapter(EObject.class) != null) - return (EObject) ((IAdaptable)selection).getAdapter(EObject.class); - + return (EObject)((IAdaptable)selection).getAdapter(EObject.class); + return null; } @@ -121,6 +130,19 @@ public class EEFDetailsPage extends AbstractFormPart implements IDetailsPage, IP public void firePropertiesChanged(IPropertiesEditionEvent event) { handleChange(event); + if (event.getState() == PropertiesEditionEvent.FOCUS_CHANGED + && event.getKind() == PropertiesEditionEvent.FOCUS_GAINED) { + // de-activate global actions + if (getEditor() instanceof InteractiveEEFEditor) { + ((InteractiveEEFEditor)getEditor()).deactivateCCPActions(); + } + } else if (event.getState() == PropertiesEditionEvent.FOCUS_CHANGED + && event.getKind() == PropertiesEditionEvent.FOCUS_LOST) { + // re-activate global actions + if (getEditor() instanceof InteractiveEEFEditor) { + ((InteractiveEEFEditor)getEditor()).activateCCPActions(); + } + } } private void handleChange(IPropertiesEditionEvent event) { @@ -130,4 +152,15 @@ public class EEFDetailsPage extends AbstractFormPart implements IDetailsPage, IP messageManager.processMessage(event); } + /** + * Retrieve the Editor from the form. + * + * @return The eef editor used to display this page. + */ + private Object getEditor() { + if (getManagedForm().getContainer() instanceof AbstractEEFMDFormPage) + return ((AbstractEEFMDFormPage)getManagedForm().getContainer()).getEditor(); + return null; + } + } diff --git a/plugins/org.eclipse.emf.eef.runtime.extended/src/org/eclipse/emf/eef/runtime/ui/widgets/masterdetails/AbstractEEFMasterDetailsBlock.java b/plugins/org.eclipse.emf.eef.runtime.extended/src/org/eclipse/emf/eef/runtime/ui/widgets/masterdetails/AbstractEEFMasterDetailsBlock.java index 0651bd33b..88c52dd66 100644 --- a/plugins/org.eclipse.emf.eef.runtime.extended/src/org/eclipse/emf/eef/runtime/ui/widgets/masterdetails/AbstractEEFMasterDetailsBlock.java +++ b/plugins/org.eclipse.emf.eef.runtime.extended/src/org/eclipse/emf/eef/runtime/ui/widgets/masterdetails/AbstractEEFMasterDetailsBlock.java @@ -42,32 +42,40 @@ import org.eclipse.ui.forms.widgets.Section; /** * @author <a href="mailto:goulwen.lefur@obeo.fr">Goulwen Le Fur</a> - * */ public abstract class AbstractEEFMasterDetailsBlock extends MasterDetailsBlock { protected FormToolkit toolkit; + protected AbstractEEFMasterPart masterPart; + protected EditingDomain editingDomain; + private AdapterFactory adapterFactory; + protected ValidateAction validateAction; + private EEFDetailsPage lastDetailsPage; - + private boolean orientable = true; + private boolean showValidateAction = true; - + /** - * Default constructor. - * The block is orientable. + * Default constructor. The block is orientable. */ public AbstractEEFMasterDetailsBlock() { super(); } /** - * Constructor defining if the orientation of the block can be changed and if the validate action is visible. - * @param isOrientable the block is orientable or not. - * @param showValidationAction defining the visibility of the action. + * Constructor defining if the orientation of the block can be changed and if the validate action is + * visible. + * + * @param isOrientable + * the block is orientable or not. + * @param showValidationAction + * defining the visibility of the action. */ public AbstractEEFMasterDetailsBlock(boolean isOrientable, boolean showValidationAction) { this(); @@ -77,7 +85,9 @@ public abstract class AbstractEEFMasterDetailsBlock extends MasterDetailsBlock { /** * {@inheritDoc} - * @see org.eclipse.ui.forms.MasterDetailsBlock#createMasterPart(org.eclipse.ui.forms.IManagedForm, org.eclipse.swt.widgets.Composite) + * + * @see org.eclipse.ui.forms.MasterDetailsBlock#createMasterPart(org.eclipse.ui.forms.IManagedForm, + * org.eclipse.swt.widgets.Composite) */ protected final void createMasterPart(IManagedForm managedForm, Composite parent) { this.toolkit = managedForm.getToolkit(); @@ -89,14 +99,15 @@ public abstract class AbstractEEFMasterDetailsBlock extends MasterDetailsBlock { Section section = masterPart.getSection(); section.setLayout(EEFFormLayoutFactory.createClearGridLayout(false, 1)); section.setLayoutData(new GridData(GridData.FILL_BOTH)); - masterPart.getModelViewer().addDoubleClickListener((new OpenWizardOnDoubleClick(editingDomain, getAdapterFactory()))); + masterPart.getModelViewer().addDoubleClickListener( + (new OpenWizardOnDoubleClick(editingDomain, getAdapterFactory()))); if (showValidateAction) { masterPart.addSelectionChangeListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { ISelection selection = event.getSelection(); if (selection instanceof IStructuredSelection) - validateAction.updateSelection((IStructuredSelection) selection); + validateAction.updateSelection((IStructuredSelection)selection); } }); @@ -105,25 +116,30 @@ public abstract class AbstractEEFMasterDetailsBlock extends MasterDetailsBlock { /** * Create contents of the Master part - * @param masterContainer the container of this contents - * @return an EEFMasterPart defining the contents of the MasterPart + * + * @param masterContainer + * the container of this contents + * @return an EEFMasterPart defining the contents of the MasterPart */ protected abstract AbstractEEFMasterPart createEEFMasterPart(Composite masterContainer); /** * {@inheritDoc} + * * @see org.eclipse.ui.forms.MasterDetailsBlock#createToolBarActions(org.eclipse.ui.forms.IManagedForm) */ protected void createToolBarActions(IManagedForm managedForm) { final ScrolledForm form = managedForm.getForm(); if (showValidateAction) { validateAction = new ValidateAction(); - validateAction.setToolTipText(EEFRuntimeUIMessages.AbstractEEFMasterDetailsBlock_validate_action_tooltip); - validateAction.setImageDescriptor(EEFRuntimePlugin.getImageDescriptor(EEFRuntimePlugin.ICONS_16x16 + "validate.gif")); //$NON-NLS-1$ + validateAction + .setToolTipText(EEFRuntimeUIMessages.AbstractEEFMasterDetailsBlock_validate_action_tooltip); + validateAction.setImageDescriptor(EEFRuntimePlugin + .getImageDescriptor(EEFRuntimePlugin.ICONS_16x16 + "validate.gif")); //$NON-NLS-1$ form.getToolBarManager().add(validateAction); } if (orientable) { - Action haction = new Action("hor", IAction.AS_RADIO_BUTTON) { //$NON-NLS-1$ + Action haction = new Action("hor", IAction.AS_RADIO_BUTTON) { //$NON-NLS-1$ public void run() { sashForm.setOrientation(SWT.HORIZONTAL); form.reflow(true); @@ -131,11 +147,13 @@ public abstract class AbstractEEFMasterDetailsBlock extends MasterDetailsBlock { }; haction.setChecked(true); haction.setToolTipText(EEFRuntimeUIMessages.AbstractEEFMasterDetailsBlock_horizontal_layout); - haction.setImageDescriptor(EEFRuntimePlugin.getImageDescriptor(EEFRuntimePlugin.ICONS_16x16 + "th_horizontal.gif")); //$NON-NLS-1$ - haction.setDisabledImageDescriptor(EEFRuntimePlugin.getImageDescriptor(EEFRuntimePlugin.ICONS_16x16 + "disabled/th_horizontal.gif")); //$NON-NLS-1$ + haction.setImageDescriptor(EEFRuntimePlugin.getImageDescriptor(EEFRuntimePlugin.ICONS_16x16 + + "th_horizontal.gif")); //$NON-NLS-1$ + haction.setDisabledImageDescriptor(EEFRuntimePlugin + .getImageDescriptor(EEFRuntimePlugin.ICONS_16x16 + "disabled/th_horizontal.gif")); //$NON-NLS-1$ form.getToolBarManager().add(haction); - Action vaction = new Action("ver", IAction.AS_RADIO_BUTTON) { //$NON-NLS-1$ + Action vaction = new Action("ver", IAction.AS_RADIO_BUTTON) { //$NON-NLS-1$ public void run() { sashForm.setOrientation(SWT.VERTICAL); form.reflow(true); @@ -143,8 +161,10 @@ public abstract class AbstractEEFMasterDetailsBlock extends MasterDetailsBlock { }; vaction.setChecked(false); vaction.setToolTipText(EEFRuntimeUIMessages.AbstractEEFMasterDetailsBlock_vertical_layout); - vaction.setImageDescriptor(EEFRuntimePlugin.getImageDescriptor(EEFRuntimePlugin.ICONS_16x16 + "th_vertical.gif")); //$NON-NLS-1$ - vaction.setDisabledImageDescriptor(EEFRuntimePlugin.getImageDescriptor(EEFRuntimePlugin.ICONS_16x16 + "disabled/th_vertical.gif")); //$NON-NLS-1$ + vaction.setImageDescriptor(EEFRuntimePlugin.getImageDescriptor(EEFRuntimePlugin.ICONS_16x16 + + "th_vertical.gif")); //$NON-NLS-1$ + vaction.setDisabledImageDescriptor(EEFRuntimePlugin + .getImageDescriptor(EEFRuntimePlugin.ICONS_16x16 + "disabled/th_vertical.gif")); //$NON-NLS-1$ form.getToolBarManager().add(vaction); } if (additionalPageActions() != null) { @@ -156,6 +176,7 @@ public abstract class AbstractEEFMasterDetailsBlock extends MasterDetailsBlock { /** * {@inheritDoc} + * * @see org.eclipse.ui.forms.MasterDetailsBlock#registerPages(org.eclipse.ui.forms.DetailsPart) */ protected void registerPages(DetailsPart detailsPart) { @@ -183,7 +204,7 @@ public abstract class AbstractEEFMasterDetailsBlock extends MasterDetailsBlock { public AbstractEEFMasterPart getMasterPart() { return masterPart; } - + /** * @return the lastDetailsPage */ @@ -193,12 +214,14 @@ public abstract class AbstractEEFMasterDetailsBlock extends MasterDetailsBlock { /** * Defines the orientation of the block. - * @param orientation the orientation to set + * + * @param orientation + * the orientation to set */ public void setOrientation(int orientation) { sashForm.setOrientation(orientation); } - + /** * @return the adapterFactory */ @@ -207,7 +230,8 @@ public abstract class AbstractEEFMasterDetailsBlock extends MasterDetailsBlock { } /** - * @param adapterFactory the adapterFactory to set + * @param adapterFactory + * the adapterFactory to set */ public void setAdapterFactory(AdapterFactory adapterFactory) { this.adapterFactory = adapterFactory; @@ -222,26 +246,29 @@ public abstract class AbstractEEFMasterDetailsBlock extends MasterDetailsBlock { } /** - * @param editingDomain the editingDomain to set + * @param editingDomain + * the editingDomain to set */ public void setEditingDomain(EditingDomain editingDomain) { this.editingDomain = editingDomain; } /** - * @param input the input of the model viewer + * @param input + * the input of the model viewer */ public void setInput(Object input) { masterPart.setInput(input); } /** - * @param filter add a filter to the model viewer + * @param filter + * add a filter to the model viewer */ public void addFilter(ViewerFilter filter) { masterPart.addFilter(filter); } - + /** * @return the list of actions to add to the form toolbar */ |