/******************************************************************************* * Copyright (c) 2000, 2018 IBM Corporation and others. * * 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 * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.tags; import java.lang.reflect.InvocationTargetException; import org.eclipse.core.runtime.*; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.TrayDialog; import org.eclipse.jface.operation.IRunnableContext; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Cursor; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.*; import org.eclipse.team.internal.ccvs.core.CVSStatus; import org.eclipse.team.internal.ccvs.core.CVSTag; import org.eclipse.team.internal.ccvs.ui.*; /** * Dialog to prompt the user to choose a tag for a selected resource */ public class TagSelectionDialog extends TrayDialog implements IPropertyChangeListener { private TagSelectionArea tagSelectionArea; public static final int INCLUDE_HEAD_TAG = TagSourceWorkbenchAdapter.INCLUDE_HEAD_TAG; public static final int INCLUDE_BASE_TAG = TagSourceWorkbenchAdapter.INCLUDE_BASE_TAG; public static final int INCLUDE_BRANCHES = TagSourceWorkbenchAdapter.INCLUDE_BRANCHES; public static final int INCLUDE_VERSIONS = TagSourceWorkbenchAdapter.INCLUDE_VERSIONS; public static final int INCLUDE_DATES = TagSourceWorkbenchAdapter.INCLUDE_DATES; public static final int INCLUDE_ALL_TAGS = TagSourceWorkbenchAdapter.INCLUDE_ALL_TAGS; private Button okButton; // dialog title, should indicate the action in which the tag selection // dialog is being shown private String title; private boolean recurse = true; // constants private static final int SIZING_DIALOG_WIDTH = 90; private static final int SIZING_DIALOG_HEIGHT = 25; private CVSTag selection; private TagSource tagSource; private String message; private int includeFlags; private String helpContext; private boolean showRecurse; public static CVSTag getTagToCompareWith(Shell shell, TagSource tagSource, int includeFlags) { TagSelectionDialog dialog = new TagSelectionDialog(shell, tagSource, CVSUIMessages.CompareWithTagAction_message, CVSUIMessages.TagSelectionDialog_Select_a_Tag_1, includeFlags, false, /* show recurse*/ IHelpContextIds.COMPARE_TAG_SELECTION_DIALOG); dialog.setBlockOnOpen(true); int result = dialog.open(); if (result == Window.CANCEL) { return null; } return dialog.getResult(); } /** * Creates a new TagSelectionDialog. * @param resource The resource to select a version for. */ public TagSelectionDialog(Shell parentShell, TagSource tagSource, String title, String message, int includeFlags, final boolean showRecurse, String helpContext) { super(parentShell); // Create a tag selection area with a custom recurse option this.tagSource = tagSource; this.message = message; this.includeFlags = includeFlags; this.helpContext = helpContext; this.showRecurse = showRecurse; this.title = title; setShellStyle(SWT.DIALOG_TRIM | SWT.RESIZE | SWT.APPLICATION_MODAL); } protected void configureShell(Shell newShell) { super.configureShell(newShell); newShell.setText(title); } protected Point getInitialSize() { final Point size= super.getInitialSize(); size.x= convertWidthInCharsToPixels(SIZING_DIALOG_WIDTH); size.y= convertHeightInCharsToPixels(SIZING_DIALOG_HEIGHT); return size; } /** * Creates this window's widgetry. *
* The default implementation of this framework method
* creates this window's shell (by calling createShell
),
* its control (by calling createContents
),
* and initializes this window's shell bounds
* (by calling initializeBounds
).
* This framework method may be overridden; however,
* super.create
must be called.
*
* The default implementation of this framework method
* creates and returns a new Composite
with
* standard margins and spacing.
* Subclasses should override.
*