diff options
Diffstat (limited to 'plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/ui/ExtendedDirectEditionDialog.java')
-rw-r--r-- | plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/ui/ExtendedDirectEditionDialog.java | 166 |
1 files changed, 9 insertions, 157 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/ui/ExtendedDirectEditionDialog.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/ui/ExtendedDirectEditionDialog.java index a79a2156bda..69a9da87549 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/ui/ExtendedDirectEditionDialog.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/ui/ExtendedDirectEditionDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006 CEA List. + * Copyright (c) 2006, 2018 CEA List. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -9,45 +9,21 @@ * * Contributors: * CEA List - initial API and implementation + * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 533667 + * *******************************************************************************/ package org.eclipse.papyrus.extensionpoints.editors.ui; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.text.Document; -import org.eclipse.jface.text.DocumentEvent; -import org.eclipse.jface.text.IDocumentListener; -import org.eclipse.jface.text.source.ISourceViewer; -import org.eclipse.jface.text.source.SourceViewer; -import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration; -import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration.Selection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.custom.VerifyKeyListener; -import org.eclipse.swt.events.VerifyEvent; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Group; +import org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors.configuration.IDirectEditorConfiguration; import org.eclipse.swt.widgets.Shell; /** * Dialog used in for direct edition, when an extension is provided + * + * @deprecated since 3.1. Use {@link org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors.ui.ExtendedDirectEditionDialog} instead. */ -public class ExtendedDirectEditionDialog extends LabelEditorDialog { - - /** Title of the Dialog */ - final private static String TITLE = "Edit Label"; - - /** Edited object */ - protected Object editedObject; - - /** Document used by the dialog */ - protected Document document; - - /** extension configuration */ - protected IDirectEditorConfiguration configuration; +@Deprecated +public class ExtendedDirectEditionDialog extends org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors.ui.ExtendedDirectEditionDialog { /** * Creates a new ExtendedDirectEditionDialog @@ -61,130 +37,6 @@ public class ExtendedDirectEditionDialog extends LabelEditorDialog { */ public ExtendedDirectEditionDialog(Shell parentShell, Object object, String initialValue, IDirectEditorConfiguration configuration) { - super(parentShell, TITLE, initialValue, configuration.getInputValidator()); - this.editedObject = object; - this.value = initialValue; - this.configuration = configuration; - } - - /** - * {@inheritDoc} - */ - @Override - protected Control createDialogArea(Composite parent) { - Group composite = new Group(parent, SWT.RESIZE); - composite.setText("Specification"); - GridLayout layout = new GridLayout(); - layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); - layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); - layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); - layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Composite viewerGroup = new Composite(composite, SWT.RESIZE); - FillLayout viewerLayout = new FillLayout(); - viewerGroup.setLayout(viewerLayout); - GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL - | GridData.VERTICAL_ALIGN_CENTER); - data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); - viewerGroup.setLayoutData(data); - viewer = new SourceViewer(viewerGroup, null, SWT.BORDER | SWT.FILL_EVEN_ODD); - - // configure source viewer - document = new Document(); - document.set(value); - - // add completion processor key listener (ctrl+space keys) - viewer.appendVerifyKeyListener(new LabelKeyListener(viewer)); - - document.addDocumentListener(new DocumentListener()); - viewer.configure(configuration.getSourceViewerConfiguration()); - viewer.setDocument(document); - - Selection selection = configuration.getTextSelection(value, editedObject); - viewer.setSelectedRange(selection.getStart(), selection.getLentgh()); - - Composite extendedArea = configuration.createExtendedDialogArea(viewerGroup); - if (extendedArea != null) { - extendedArea.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); - } - - errorMessageText = new CLabel(composite, SWT.READ_ONLY | SWT.SHADOW_NONE); - errorMessageText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); - errorMessageText.setBackground(errorMessageText.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); - // Set the error message text - // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=66292 - setErrorMessage(errorMessage); - - applyDialogFont(composite); - return composite; + super(parentShell, object, initialValue, configuration); } - - /** - * - */ - private class LabelKeyListener implements VerifyKeyListener { - - /** - * - */ - SourceViewer viewer; - - /** - * Default constructor. - * - * @param viewer - */ - public LabelKeyListener(SourceViewer viewer) { - this.viewer = viewer; - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.swt.custom.VerifyKeyListener#verifyKey(org.eclipse.swt.events.VerifyEvent) - */ - /** - * - * - * @param event - */ - public void verifyKey(VerifyEvent event) { - if ((event.stateMask == SWT.CTRL) && (event.character == ' ')) { - if (viewer.canDoOperation(ISourceViewer.CONTENTASSIST_PROPOSALS)) { - viewer.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS); - } - event.doit = false; - } else if (event.character == SWT.CR) { - event.doit = false; - } - } - } - - /** - * - */ - private class DocumentListener implements IDocumentListener { - - /** - * - * - * @param event - */ - public void documentAboutToBeChanged(DocumentEvent event) { - } - - /** - * - * - * @param event - */ - public void documentChanged(DocumentEvent event) { - validateInput(); - } - - } - } |