diff options
Diffstat (limited to 'bundles/org.eclipse.team.cvs.ui/src/org')
12 files changed, 870 insertions, 415 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AvoidableMessageDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AvoidableMessageDialog.java index 1754edd0b..03d67d968 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AvoidableMessageDialog.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AvoidableMessageDialog.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/cpl-v05.html * * Contributors: - * IBM - Initial API and implementation + * IBM - Initial implementation ******************************************************************************/ package org.eclipse.team.internal.ccvs.ui; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/BranchPromptDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/BranchPromptDialog.java new file mode 100644 index 000000000..0a33d744d --- /dev/null +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/BranchPromptDialog.java @@ -0,0 +1,273 @@ +/******************************************************************************* + * Copyright (c) 2002 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM - Initial implementation + ******************************************************************************/ +package org.eclipse.team.internal.ccvs.ui; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.team.internal.ccvs.core.CVSTag; +import org.eclipse.team.internal.ccvs.core.ICVSFolder; +import org.eclipse.team.internal.ccvs.ui.merge.ProjectElement; +import org.eclipse.team.internal.ccvs.ui.wizards.CVSWizardPage; +import org.eclipse.ui.model.WorkbenchContentProvider; +import org.eclipse.ui.model.WorkbenchLabelProvider; + +public class BranchPromptDialog extends DetailsDialog { + + private ICVSFolder folder; + private String branchTag = ""; + private String versionTag= ""; + private String versionName= ""; + + private boolean allStickyResources; + private boolean update; + + private Text versionText; + private Text branchText; + + private static final int TABLE_HEIGHT_HINT = 150; + + // widgets; + private TreeViewer tagTree; + + public BranchPromptDialog(Shell parentShell, String title, ICVSFolder folder, boolean allResourcesSticky, String versionName) { + super(parentShell, title); + this.folder = folder; + this.allStickyResources = allResourcesSticky; + this.versionName = versionName; + } + + /** + * @see DetailsDialog#createMainDialogArea(Composite) + */ + protected void createMainDialogArea(Composite composite) { + // create message + Label label = new Label(composite, SWT.WRAP); + String message; + if(allStickyResources) { + message = Policy.bind("BranchWizardPage.pageDescriptionVersion"); //$NON-NLS-1$ + } else { + message = Policy.bind("BranchWizardPage.pageDescription"); //$NON-NLS-1$ + } + label.setText(message); + 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);; + label.setLayoutData(data); + label.setFont(composite.getFont()); + + CVSWizardPage.createLabel(composite, Policy.bind("BranchWizardPage.branchName")); //$NON-NLS-1$ + branchText = CVSWizardPage.createTextField(composite); + branchText.addListener(SWT.Modify, new Listener() { + public void handleEvent(Event event) { + branchTag = branchText.getText(); + updateEnablements(); + updateVersionName(branchTag); + } + }); + + final Button check = new Button(composite, SWT.CHECK); + data = new GridData(); + data.horizontalSpan = 2; + check.setLayoutData(data); + check.setText(Policy.bind("BranchWizardPage.startWorking")); //$NON-NLS-1$ + check.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event event) { + update = check.getSelection(); + } + }); + check.setSelection(true); + update = true; + + label = new Label(composite, SWT.WRAP); + label.setText(Policy.bind("BranchWizardPage.specifyVersion")); //$NON-NLS-1$ + data = new GridData(); + data.horizontalSpan = 2; + data.widthHint = 350; + label.setLayoutData(data); + + CVSWizardPage.createLabel(composite, Policy.bind("BranchWizardPage.versionName")); //$NON-NLS-1$ + versionText = CVSWizardPage.createTextField(composite); + versionText.addListener(SWT.Modify, new Listener() { + public void handleEvent(Event event) { + versionTag = versionText.getText(); + updateEnablements(); + } + }); + + if(allStickyResources) { + versionText.setEditable(false); + versionText.setText(versionName); + } + + branchText.setFocus(); + } + + /** + * Updates version name + */ + protected void updateVersionName(String branchName) { + if(versionText!=null && !allStickyResources) { + versionText.setText(Policy.bind("BranchWizardPage.versionPrefix") + branchName); //$NON-NLS-1$ + } + } + + /** + * @see DetailsDialog#createDropDownDialogArea(Composite) + */ + protected Composite createDropDownDialogArea(Composite parent) { + + // create a composite with standard margins and spacing + Composite composite = new Composite(parent, SWT.NONE); + 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.setFont(parent.getFont()); + + tagTree = createTree(composite); + tagTree.setInput(new ProjectElement(folder, false /*show HEAD tag*/)); + Runnable refresh = new Runnable() { + public void run() { + getShell().getDisplay().syncExec(new Runnable() { + public void run() { + tagTree.refresh(); + } + }); + } + }; + TagConfigurationDialog.createTagDefinitionButtons(getShell(), composite, new ICVSFolder[] {folder}, + convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT), + convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH), + refresh, refresh); + return composite; + } + + /** + * Creates the existing branch and version tree viewer in the details pane + */ + protected TreeViewer createTree(Composite parent) { + Tree tree = new Tree(parent, SWT.SINGLE | SWT.BORDER); + GridData data = new GridData(GridData.FILL_BOTH); + data.heightHint = TABLE_HEIGHT_HINT; + tree.setLayoutData(data); + TreeViewer result = new TreeViewer(tree); + result.setContentProvider(new WorkbenchContentProvider()); + result.setLabelProvider(new WorkbenchLabelProvider()); + result.addSelectionChangedListener(new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent event) { + } + }); + result.setSorter(new RepositorySorter()); + return result; + } + + /** + * Validates branch and version names + */ + protected void updateEnablements() { + String message = null; + + if (branchTag.length() == 0) { + message = null; + } else { + IStatus status = CVSTag.validateTagName(branchTag); + if (!status.isOK()) { + message = Policy.bind("BranchWizard.branchNameWarning", status.getMessage()); //$NON-NLS-1$ + } else { + if(versionText!=null) { + status = CVSTag.validateTagName(versionText.getText()); + if (!status.isOK()) { + message = Policy.bind("BranchWizard.versionNameWarning", status.getMessage()); //$NON-NLS-1$ + } else { + if(versionTag.equals(branchTag)) { + message = Policy.bind("BranchWizard.branchAndVersionMustBeDifferent"); //$NON-NLS-1$ + } else { + if(doesTagNameExists(versionTag)) { + message = Policy.bind("BranchWizard.versionNameAlreadyExists"); //$NON-NLS-1$ + } else if(doesBranchNameExists(branchTag)) { + message = Policy.bind("BranchWizard.branchNameAlreadyExists"); //$NON-NLS-1$ + } + } + } + } + } + } + setErrorMessage(message); + } + + /** + * Answers if the given tag name already exists + */ + protected boolean doesTagNameExists(String name) { + CVSTag[] tags = CVSUIPlugin.getPlugin().getRepositoryManager().getKnownVersionTags(folder); + for (int i = 0; i < tags.length; i++) { + if(tags[i].getName().equals(name)) { + return true; + } + } + return false; + } + + /** + * Answers if the given branch name already exists + */ + protected boolean doesBranchNameExists(String name) { + CVSTag[] tags = CVSUIPlugin.getPlugin().getRepositoryManager().getKnownBranchTags(folder); + for (int i = 0; i < tags.length; i++) { + if(tags[i].getName().equals(name)) { + return true; + } + } + return false; + } + + + /** + * Returns the branch tag name + */ + public String getBranchTagName() { + return branchTag; + } + + /** + * Returns the version tag name + */ + public String getVersionTagName() { + return versionTag; + } + + /** + * Returns the state of the update checkbox + */ + public boolean getUpdate() { + return update; + } +} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/DetailsDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/DetailsDialog.java new file mode 100644 index 000000000..1a223864b --- /dev/null +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/DetailsDialog.java @@ -0,0 +1,187 @@ +/******************************************************************************* + * Copyright (c) 2002 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM - Initial implementation + ******************************************************************************/ +package org.eclipse.team.internal.ccvs.ui; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; + +/** + * A simple superclass for detail button dialogs. + */ +abstract public class DetailsDialog extends Dialog { + /** + * The Details button. + */ + private Button detailsButton; + + /** + * The Ok button. + */ + private Button okButton; + + /** + * The title of the dialog. + */ + private String title; + + /** + * The error message + */ + private Label errorMessageLabel; + + /** + * The SWT list control that displays the error details. + */ + private Composite detailsComposite; + + /** + * Indicates whether the error details viewer is currently created. + */ + private boolean detailsCreated = false; + + /** + * Creates a details pane dialog. + * Note that the dialog will have no visual representation (no widgets) + * until it is told to open. + * + * @param parentShell the shell under which to create this dialog + * @param dialogTitle the title to use for this dialog + * @param message the message to show in this dialog + * @param status the error to show to the user + * @param displayMask the mask to use to filter the displaying of child items, + * as per <code>IStatus.matches</code> + * @see org.eclipse.core.runtime.IStatus#matches + */ + public DetailsDialog(Shell parentShell, String dialogTitle) { + super(parentShell); + this.title = dialogTitle; + setShellStyle(SWT.DIALOG_TRIM | SWT.RESIZE | SWT.APPLICATION_MODAL); + } + + /* (non-Javadoc) + * Method declared on Dialog. + * Handles the pressing of the Ok or Details button in this dialog. + * If the Ok button was pressed then close this dialog. If the Details + * button was pressed then toggle the displaying of the error details area. + * Note that the Details button will only be visible if the error being + * displayed specifies child details. + */ + protected void buttonPressed(int id) { + if (id == IDialogConstants.DETAILS_ID) { // was the details button pressed? + toggleDetailsArea(); + } else { + super.buttonPressed(id); + } + } + + /* (non-Javadoc) + * Method declared in Window. + */ + protected void configureShell(Shell shell) { + super.configureShell(shell); + shell.setText(title); + } + + /* (non-Javadoc) + * Method declared on Dialog. + */ + protected void createButtonsForButtonBar(Composite parent) { + // create OK and Details buttons + okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); + createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); + detailsButton = createButton(parent, IDialogConstants.DETAILS_ID, IDialogConstants.SHOW_DETAILS_LABEL, false); + } + + /* (non-Javadoc) + * Method declared on Dialog. + * Creates and returns the contents of the upper part + * of the dialog (above the button bar). + */ + final protected Control createDialogArea(Composite parent) { + // create composite + Composite composite = (Composite)super.createDialogArea(parent); + + createMainDialogArea(composite); + + errorMessageLabel = new Label(composite, SWT.NONE); + errorMessageLabel.setLayoutData(new GridData( + GridData.GRAB_HORIZONTAL | + GridData.HORIZONTAL_ALIGN_FILL)); + errorMessageLabel.setFont(parent.getFont()); + errorMessageLabel.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_RED)); + + updateEnablements(); + + return composite; + } + + /** + * Creates the dialog's top composite + * + * @param parent the parent composite + */ + abstract protected void createMainDialogArea(Composite parent); + + /** + * Create this dialog's drop-down list component. + * + * @param parent the parent composite + * @return the drop-down list component + */ + abstract protected Composite createDropDownDialogArea(Composite parent); + + /** + * Toggles the unfolding of the details area. This is triggered by + * the user pressing the details button. + */ + private void toggleDetailsArea() { + Point windowSize = getShell().getSize(); + Point oldSize = getContents().computeSize(SWT.DEFAULT, SWT.DEFAULT); + + if (detailsCreated) { + detailsComposite.dispose(); + detailsCreated = false; + detailsButton.setText(IDialogConstants.SHOW_DETAILS_LABEL); + } else { + detailsComposite = createDropDownDialogArea((Composite)getContents()); + detailsCreated = true; + detailsButton.setText(IDialogConstants.HIDE_DETAILS_LABEL); + } + + Point newSize = getContents().computeSize(SWT.DEFAULT, SWT.DEFAULT); + + getShell().setSize(new Point(windowSize.x, windowSize.y + (newSize.y - oldSize.y))); + } + + final protected void setErrorMessage(String error) { + if(errorMessageLabel != null && okButton != null) { + if(error == null || error.length() == 0) { + errorMessageLabel.setText(""); + okButton.setEnabled(true); + } else { + errorMessageLabel.setText(error); + okButton.setEnabled(false); + } + errorMessageLabel.update(); + } + } + + abstract protected void updateEnablements(); +} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagAsVersionDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagAsVersionDialog.java new file mode 100644 index 000000000..d7c81c0d2 --- /dev/null +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagAsVersionDialog.java @@ -0,0 +1,210 @@ +/******************************************************************************* + * Copyright (c) 2002 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM - Initial implementation + ******************************************************************************/ +package org.eclipse.team.internal.ccvs.ui; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.jface.viewers.DoubleClickEvent; +import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.TableLayout; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerSorter; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.Text; +import org.eclipse.team.internal.ccvs.core.CVSTag; +import org.eclipse.team.internal.ccvs.core.ICVSFolder; +import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; +import org.eclipse.team.internal.ccvs.ui.merge.TagElement; +import org.eclipse.team.internal.ccvs.ui.merge.TagRootElement; +import org.eclipse.ui.model.WorkbenchContentProvider; +import org.eclipse.ui.model.WorkbenchLabelProvider; + +public class TagAsVersionDialog extends DetailsDialog { + + private ICVSFolder folder; + + private Text tagText; + + private String tagName; + + private static final int TABLE_HEIGHT_HINT = 150; + + private TableViewer existingVersionTable; + + public TagAsVersionDialog(Shell parentShell, String title, ICVSFolder folder) { + super(parentShell, title); + this.folder = folder; + } + + /** + * @see DetailsDialog#createMainDialogArea(Composite) + */ + protected void createMainDialogArea(Composite parent) { + // create message + Label label = new Label(parent, SWT.WRAP); + label.setText(Policy.bind("TagAction.enterTag")); + 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);; + label.setLayoutData(data); + label.setFont(parent.getFont()); + + tagText = new Text(parent, SWT.SINGLE | SWT.BORDER); + tagText.setLayoutData(new GridData( + GridData.GRAB_HORIZONTAL | + GridData.HORIZONTAL_ALIGN_FILL)); + tagText.addModifyListener( + new ModifyListener() { + public void modifyText(ModifyEvent e) { + tagName = tagText.getText(); + updateEnablements(); + } + } + ); + } + + protected TableViewer createTable(Composite parent) { + Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION); + GridData data = new GridData(GridData.FILL_BOTH); + data.heightHint = TABLE_HEIGHT_HINT; + table.setLayoutData(data); + TableLayout layout = new TableLayout(); + layout.addColumnData(new ColumnWeightData(100, true)); + table.setLayout(layout); + TableColumn col = new TableColumn(table, SWT.NONE); + col.setResizable(true); + + return new TableViewer(table); + } + + /** + * @see DetailsDialog#createDropDownDialogArea(Composite) + */ + protected Composite createDropDownDialogArea(Composite parent) { + // create a composite with standard margins and spacing + Composite composite = new Composite(parent, SWT.NONE); + 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.setFont(parent.getFont()); + + existingVersionTable = createTable(composite); + existingVersionTable.setContentProvider(new WorkbenchContentProvider()); + existingVersionTable.setLabelProvider(new WorkbenchLabelProvider()); + existingVersionTable.setSorter(new ViewerSorter() { + public int compare(Viewer v, Object o1, Object o2) { + int result = super.compare(v, o1, o2); + if (o1 instanceof TagElement && o2 instanceof TagElement) { + return -result; + } + return result; + } + }); + existingVersionTable.addSelectionChangedListener(new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent event) { + IStructuredSelection selection = (IStructuredSelection)existingVersionTable.getSelection(); + if(!selection.isEmpty()) { + TagElement element = (TagElement)((IStructuredSelection)existingVersionTable.getSelection()).getFirstElement(); + if(element!=null) { + tagText.setText(element.getTag().getName()); + } + } + } + }); + + Runnable afterRefresh = new Runnable() { + public void run() { + getShell().getDisplay().syncExec(new Runnable() { + public void run() { + existingVersionTable.refresh(); + } + }); + } + }; + + Runnable afterConfigure = new Runnable() { + public void run() { + getShell().getDisplay().syncExec(new Runnable() { + public void run() { + existingVersionTable.setInput(new TagRootElement(folder, CVSTag.VERSION)); + } + }); + } + }; + + TagConfigurationDialog.createTagDefinitionButtons(getShell(), composite, new ICVSFolder[] {folder}, + convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT), + convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH), + afterRefresh, afterConfigure); + + existingVersionTable.setInput(new TagRootElement(folder, CVSTag.VERSION)); + + return composite; + } + + /** + * Validates tag name + */ + protected void updateEnablements() { + IStatus status = CVSTag.validateTagName(tagName); + String message = null; + if (!status.isOK()) { + message = status.getMessage(); + } + + boolean exists = doesTagNameExists(tagName); + if(exists) { + message = Policy.bind("TagAction.tagAlreadyExists"); //$NON-NLS-1$ + } + setErrorMessage(message); + } + + /** + * Answers if the given tag name already exists + */ + protected boolean doesTagNameExists(String name) { + CVSTag[] tags = CVSUIPlugin.getPlugin().getRepositoryManager().getKnownVersionTags(folder); + for (int i = 0; i < tags.length; i++) { + if(tags[i].getName().equals(name)) { + return true; + } + } + return false; + } + + /** + * Returns the tag name entered into this dialog + */ + public String getTagName() { + return tagName; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagConfigurationDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagConfigurationDialog.java index f9da220e2..f652e3cb0 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagConfigurationDialog.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagConfigurationDialog.java @@ -627,7 +627,7 @@ public class TagConfigurationDialog extends Dialog { private static void updateToolTipHelpForRefreshButton(Button button, ICVSFolder folder) { StringBuffer tooltip = new StringBuffer(Policy.bind("TagConfigurationDialog.15")); //$NON-NLS-1$ String[] autoFiles = CVSUIPlugin.getPlugin().getRepositoryManager().getAutoRefreshFiles(folder); - tooltip.append(" - .project\n"); //$NON-NLS-1$ + tooltip.append("\n - .project\n"); //$NON-NLS-1$ for (int i = 0; i < autoFiles.length; i++) { tooltip.append("- " + autoFiles[i] + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java index fb5719042..1df7337cf 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java @@ -10,31 +10,125 @@ ******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.actions; +import java.lang.reflect.InvocationTargetException; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.jface.action.IAction; -import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.jface.dialogs.InputDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.swt.widgets.Shell; import org.eclipse.team.core.TeamException; +import org.eclipse.team.internal.ccvs.core.CVSException; +import org.eclipse.team.internal.ccvs.core.CVSTag; +import org.eclipse.team.internal.ccvs.core.CVSTeamProvider; +import org.eclipse.team.internal.ccvs.core.ICVSFile; +import org.eclipse.team.internal.ccvs.core.ICVSFolder; +import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; +import org.eclipse.team.internal.ccvs.core.ICVSResource; +import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; +import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; +import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; +import org.eclipse.team.internal.ccvs.ui.BranchPromptDialog; import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.wizards.BranchWizard; +import org.eclipse.team.internal.ccvs.ui.Policy; +import org.eclipse.team.internal.ccvs.ui.RepositoryManager; /** * BranchAction tags the selected resources with a branch tag specified by the user, * and optionally updates the local resources to point to the new branch. */ public class BranchAction extends CVSAction { + /* * @see CVSAction#execute() */ public void execute(IAction action) { final Shell shell = getShell(); - shell.getDisplay().syncExec(new Runnable() { - public void run() { - BranchWizard wizard = new BranchWizard(); - wizard.setResources(getSelectedResources()); - WizardDialog dialog = new WizardDialog(shell, wizard); - dialog.open(); + final IResource[] resources = getSelectedResources(); + boolean allSticky = areAllResourcesSticky(resources); + + ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(resources[0].getProject()); + final BranchPromptDialog dialog = new BranchPromptDialog(getShell(), + Policy.bind("BranchWizard.title"), //$NON-NLS-1$ + folder, + allSticky, + calculateInitialVersionName(resources,allSticky)); + + if (dialog.open() != InputDialog.OK) return; + + run(new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + try { + String tagString = dialog.getBranchTagName(); + boolean update = dialog.getUpdate(); + String versionString = dialog.getVersionTagName(); + CVSTag rootVersionTag = null; + final CVSTag branchTag = new CVSTag(tagString, CVSTag.BRANCH); + if (versionString != null) { + rootVersionTag = new CVSTag(versionString, CVSTag.VERSION); + } + + // For non-projects determine if the tag being loaded is the same as the resource's parent + // If it's not, warn the user that they will have strange sync behavior + if (update) { + if(!CVSAction.checkForMixingTags(getShell(), resources, branchTag)) { + return; + } + } + + RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager(); + Hashtable table = getProviderMapping(resources); + Set keySet = table.keySet(); + monitor.beginTask("", keySet.size() * 1000); //$NON-NLS-1$ + MultiStatus status = new MultiStatus(CVSUIPlugin.ID, IStatus.INFO, Policy.bind("BranchWizard.errorTagging"), null); //$NON-NLS-1$ + Iterator iterator = keySet.iterator(); + while (iterator.hasNext()) { + IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1000); + CVSTeamProvider provider = (CVSTeamProvider)iterator.next(); + List list = (List)table.get(provider); + IResource[] providerResources = (IResource[])list.toArray(new IResource[list.size()]); + ICVSRepositoryLocation root = provider.getCVSWorkspaceRoot().getRemoteLocation(); + try { + if (!areAllResourcesSticky(resources)) { + // version everything in workspace with the root version tag specified in dialog + provider.makeBranch(providerResources, rootVersionTag, branchTag, update, true, subMonitor); + } else { + // all resources are versions, use that version as the root of the branch + provider.makeBranch(providerResources, null, branchTag, update, true, subMonitor); + } + if (rootVersionTag != null || update) { + for (int i = 0; i < providerResources.length; i++) { + ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(providerResources[i]); + if (rootVersionTag != null) { + manager.addVersionTags(cvsResource, new CVSTag[] { rootVersionTag }); + } + if (update) { + manager.addBranchTags(cvsResource, new CVSTag[] { branchTag }); + } + } + } + } catch (TeamException e) { + status.merge(e.getStatus()); + } + } + if (!status.isOK()) { + throw new InvocationTargetException(new CVSException(status)); + } + } catch(CVSException e) { + throw new InvocationTargetException(e); + } } - }); + }, Policy.bind("BranchWizard.errorBranching"), this.PROGRESS_DIALOG); //$NON-NLS-1$ } /* @@ -48,5 +142,62 @@ public class BranchAction extends CVSAction { return false; } } + + /** + * Answers <code>true</code> if all resources in the array have a sticky tag + */ + private boolean areAllResourcesSticky(IResource[] resources) { + for (int i = 0; i < resources.length; i++) { + if(!hasStickyTag(resources[i])) return false; + } + return true; + } + + /** + * Answers <code>true</code> if the resource has a sticky tag + */ + private boolean hasStickyTag(IResource resource) { + try { + ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); + CVSTag tag; + if(cvsResource.isFolder()) { + FolderSyncInfo folderInfo = ((ICVSFolder)cvsResource).getFolderSyncInfo(); + tag = folderInfo.getTag(); + } else { + ResourceSyncInfo info = cvsResource.getSyncInfo(); + tag = info.getTag(); + } + if(tag!=null) { + int tagType = tag.getType(); + if(tagType==tag.VERSION) { + return true; + } + } + } catch(CVSException e) { + CVSUIPlugin.log(e.getStatus()); + return false; + } + return false; + } + + private String calculateInitialVersionName(IResource[] resources, boolean allSticky) { + String versionName = ""; //$NON-NLS-1$ + try { + if(allSticky) { + IResource stickyResource = resources[0]; + if(stickyResource.getType()==IResource.FILE) { + ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile)stickyResource); + versionName = cvsFile.getSyncInfo().getTag().getName(); + } else { + ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor((IContainer)stickyResource); + versionName = cvsFolder.getFolderSyncInfo().getTag().getName(); + } + } + } catch(CVSException e) { + CVSUIPlugin.log(e.getStatus()); + versionName = ""; //$NON-NLS-1$ + } + return versionName; + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java index 301190a96..aaf878522 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java @@ -54,24 +54,31 @@ public class TagAction extends TeamAction { final int[] failureCount = new int[] {0}; final int[] resourceCount = new int[] {0}; + PromptingDialog prompt = new PromptingDialog(getShell(), getSelectedResources(), + getPromptCondition(), Policy.bind("TagAction.uncommittedChangesTitle"));//$NON-NLS-1$ + final IResource[] resources; + try { + resources = prompt.promptForMultiple(); + } catch(InterruptedException e) { + return; + } + if(resources.length == 0) { + // nothing to do + return; + } + + resourceCount[0] = resources.length; + final String[] result = new String[1]; + getShell().getDisplay().syncExec(new Runnable() { + public void run() { + ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(resources[0].getProject()); + result[0] = promptForTag(folder); + } + }); + if (result[0] == null) return; + run(new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - PromptingDialog prompt = new PromptingDialog(getShell(), getSelectedResources(), - getPromptCondition(), Policy.bind("TagAction.uncommittedChangesTitle"));//$NON-NLS-1$ - IResource[] resources = prompt.promptForMultiple(); - if(resources.length == 0) { - // nothing to do - return; - } - - resourceCount[0] = resources.length; - final String[] result = new String[1]; - getShell().getDisplay().syncExec(new Runnable() { - public void run() { - result[0] = promptForTag(); - } - }); - if (result[0] == null) return; Hashtable table = getProviderMapping(resources); Set keySet = table.keySet(); monitor.beginTask(null, keySet.size() * 1000); @@ -159,22 +166,12 @@ public class TagAction extends TeamAction { * Note: This method is designed to be overridden by test cases. * @return the tag, or null to cancel */ - protected String promptForTag() { - // Prompt for the tag - IInputValidator validator = new IInputValidator() { - public String isValid(String tagName) { - IStatus status = CVSTag.validateTagName(tagName); - if (status.isOK()) { - return null; - } else { - return status.getMessage(); - } - } - }; - InputDialog dialog = new InputDialog(getShell(), - Policy.bind("TagAction.tagResources"), Policy.bind("TagAction.enterTag"), previousTag, validator); //$NON-NLS-1$ //$NON-NLS-2$ + protected String promptForTag(ICVSFolder folder) { + TagAsVersionDialog dialog = new TagAsVersionDialog(getShell(), + Policy.bind("TagAction.tagResources"), + folder); if (dialog.open() != InputDialog.OK) return null; - return dialog.getValue(); + return dialog.getTagName(); } /** * Note: This method is designed to be overridden by test cases. diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagInRepositoryAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagInRepositoryAction.java index 95fbf2cd9..68e28178a 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagInRepositoryAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagInRepositoryAction.java @@ -71,15 +71,15 @@ public class TagInRepositoryAction extends TagAction { run(new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { try { + final ICVSRemoteFolder[] folders = getSelectedRemoteFolders(); final String[] result = new String[1]; getShell().getDisplay().syncExec(new Runnable() { public void run() { - result[0] = promptForTag(); + result[0] = promptForTag(folders[0]); } }); if (result[0] == null) return; - ICVSRemoteFolder[] folders = getSelectedRemoteFolders(); monitor.beginTask(null, 1000 * folders.length); CVSTag tag = new CVSTag(result[0], CVSTag.VERSION); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties index 1efe98db8..f8a408a29 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties @@ -28,9 +28,8 @@ AutoDefineTagsAction.defineTags = Auto-discover tags AvoidableMessageDialog.dontShowAgain=Don't show this again -BranchWizard.createABranch=Creates a new CVS Branch -BranchWizard.title=Branch -BranchWizard.errorTagging=Error Tagging Resources +BranchWizard.title=Create a new CVS Branch +BranchWizard.errorBranching=Error Branching Resources BranchWizardPage.pageDescription=Creates a new branch and a starting point version. BranchWizardPage.pageDescriptionVersion=Creates a new branch based on the version in the workspace. BranchWizardPage.specifyVersion=The version will provide a starting point for merging the branch back to the source branch. @@ -40,8 +39,9 @@ BranchWizardPage.startWorking=Start working in the branch BranchWizardPage.versionPrefix=Root_ BranchWizard.versionNameWarning=Version name: {0} BranchWizard.branchNameWarning=Branch name: {0} - BranchWizard.branchAndVersionMustBeDifferent=The branch name and version name must be different. +BranchWizard.branchNameAlreadyExists=Branch name already exists. +BranchWizard.versionNameAlreadyExists=Version name already exists. ConsolePreferencePage.consoleColorSettings=Console text color settings. ConsolePreferencePage.commandColor=Command &Line: @@ -510,6 +510,7 @@ TagAction.tagResources=Tag Resources TagAction.enterTag=Please enter a version tag: TagAction.uncommittedChangesTitle=Confirm Uncommitted Changes TagAction.uncommittedChanges=You are tagging ''{0}'' that has uncommitted changes. These changes are not in the repository and will not be included in the version you are creating. Do you still want to tag this resource? +TagAction.tagAlreadyExists=Version tag already exists. UpdateAction.update=Problems encountered performing update UpdateAction.updating=Updating... diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/BranchWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/BranchWizard.java deleted file mode 100644 index e5b61a39b..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/BranchWizard.java +++ /dev/null @@ -1,207 +0,0 @@ -package org.eclipse.team.internal.ccvs.ui.wizards; - -/* - * (c) Copyright IBM Corp. 2000, 2002. - * All Rights Reserved. - */ - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.CVSTeamProvider; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.ICVSResource; -import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.RepositoryManager; -import org.eclipse.team.internal.ccvs.ui.actions.CVSAction; - -public class BranchWizard extends Wizard { - BranchWizardPage mainPage; - IResource[] resources; - - public BranchWizard() { - setNeedsProgressMonitor(true); - setWindowTitle(Policy.bind("BranchWizard.title")); //$NON-NLS-1$ - } - - public void addPages() { - boolean allResourcesSticky = areAllResourcesSticky(resources); - String versionName = ""; //$NON-NLS-1$ - try { - if(allResourcesSticky) { - IResource stickyResource = resources[0]; - if(stickyResource.getType()==IResource.FILE) { - ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile)stickyResource); - versionName = cvsFile.getSyncInfo().getTag().getName(); - } else { - ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor((IContainer)stickyResource); - versionName = cvsFolder.getFolderSyncInfo().getTag().getName(); - } - } - } catch(CVSException e) { - CVSUIPlugin.log(e.getStatus()); - versionName = ""; //$NON-NLS-1$ - } - mainPage = new BranchWizardPage("versionPage", Policy.bind("BranchWizard.createABranch"), allResourcesSticky, versionName, CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_BRANCH)); //$NON-NLS-1$ //$NON-NLS-2$ - addPage(mainPage); - } - public boolean performFinish() { - final boolean[] result = new boolean[] {false}; - try { - getContainer().run(false, false, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException { - try { - String tagString = mainPage.getBranchTag(); - boolean update = mainPage.getUpdate(); - String versionString = mainPage.getVersionTag(); - CVSTag rootVersionTag = null; - final CVSTag branchTag = new CVSTag(tagString, CVSTag.BRANCH); - if (versionString != null) { - rootVersionTag = new CVSTag(versionString, CVSTag.VERSION); - } - - // For non-projects determine if the tag being loaded is the same as the resource's parent - // If it's not, warn the user that they will have strange sync behavior - if (update) { - if(!CVSAction.checkForMixingTags(getShell(), resources, branchTag)) { - return; - } - } - - RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager(); - Hashtable table = getProviderMapping(resources); - Set keySet = table.keySet(); - monitor.beginTask("", keySet.size() * 1000); //$NON-NLS-1$ - MultiStatus status = new MultiStatus(CVSUIPlugin.ID, IStatus.INFO, Policy.bind("BranchWizard.errorTagging"), null); //$NON-NLS-1$ - Iterator iterator = keySet.iterator(); - while (iterator.hasNext()) { - IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1000); - CVSTeamProvider provider = (CVSTeamProvider)iterator.next(); - List list = (List)table.get(provider); - IResource[] providerResources = (IResource[])list.toArray(new IResource[list.size()]); - ICVSRepositoryLocation root = provider.getCVSWorkspaceRoot().getRemoteLocation(); - try { - if (!areAllResourcesSticky(resources)) { - // version everything in workspace with the root version tag specified in dialog - provider.makeBranch(providerResources, rootVersionTag, branchTag, update, true, subMonitor); - } else { - // all resources are versions, use that version as the root of the branch - provider.makeBranch(providerResources, null, branchTag, update, true, subMonitor); - } - if (rootVersionTag != null || update) { - for (int i = 0; i < providerResources.length; i++) { - ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(providerResources[i]); - if (rootVersionTag != null) { - manager.addVersionTags(cvsResource, new CVSTag[] { rootVersionTag }); - } - if (update) { - manager.addBranchTags(cvsResource, new CVSTag[] { branchTag }); - } - } - } - } catch (TeamException e) { - status.merge(e.getStatus()); - } - } - if (!status.isOK()) { - ErrorDialog.openError(getShell(), null, null, status); - } - result[0] = true; - } catch (CVSException e) { - throw new InvocationTargetException(e); - } finally { - monitor.done(); - } - } - }); - } catch (InterruptedException e) { - return true; - } catch (InvocationTargetException e) { - Throwable target = e.getTargetException(); - if (target instanceof CVSException) { - ErrorDialog.openError(getShell(), null, null, ((CVSException)target).getStatus()); - return false; - } - if (target instanceof RuntimeException) { - throw (RuntimeException)target; - } - if (target instanceof Error) { - throw (Error)target; - } - } - return result[0]; - } - public void setResources(IResource[] resources) { - this.resources = resources; - } - private Hashtable getProviderMapping(IResource[] resources) { - Hashtable result = new Hashtable(); - for (int i = 0; i < resources.length; i++) { - RepositoryProvider provider = RepositoryProvider.getProvider(resources[i].getProject(), CVSProviderPlugin.getTypeId()); - List list = (List)result.get(provider); - if (list == null) { - list = new ArrayList(); - result.put(provider, list); - } - list.add(resources[i]); - } - return result; - } - - private boolean areAllResourcesSticky(IResource[] resources) { - for (int i = 0; i < resources.length; i++) { - if(!hasStickyTag(resources[i])) return false; - } - return true; - } - - private boolean hasStickyTag(IResource resource) { - try { - ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); - CVSTag tag; - if(cvsResource.isFolder()) { - FolderSyncInfo folderInfo = ((ICVSFolder)cvsResource).getFolderSyncInfo(); - tag = folderInfo.getTag(); - } else { - ResourceSyncInfo info = cvsResource.getSyncInfo(); - tag = info.getTag(); - } - if(tag!=null) { - int tagType = tag.getType(); - if(tagType==tag.VERSION) { - return true; - } - } - } catch(CVSException e) { - CVSUIPlugin.log(e.getStatus()); - return false; - } - return false; - } -} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/BranchWizardPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/BranchWizardPage.java deleted file mode 100644 index 4503c4814..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/BranchWizardPage.java +++ /dev/null @@ -1,157 +0,0 @@ -package org.eclipse.team.internal.ccvs.ui.wizards; - -/* - * (c) Copyright IBM Corp. 2000, 2002. - * All Rights Reserved. - */ - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Text; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.ui.Policy; - -public class BranchWizardPage extends CVSWizardPage { - boolean update; - - String branchTag; - String versionTag; - String versionName; - boolean allStickyResources; - - Text versionText; - Text branchText; - - public BranchWizardPage(String pageName,String title, boolean allStickyResources, String versionName, ImageDescriptor titleImage) { - super(pageName, title, titleImage); - if(allStickyResources) { - setDescription(Policy.bind("BranchWizardPage.pageDescriptionVersion")); //$NON-NLS-1$ - } else { - setDescription(Policy.bind("BranchWizardPage.pageDescription")); //$NON-NLS-1$ - } - this.allStickyResources = allStickyResources; - this.versionName = versionName; - } - - /* - * @see IDialogPage#createControl(Composite) - */ - public void createControl(Composite parent) { - Composite composite = createComposite(parent, 2); - Label label; - GridData data; - - createLabel(composite, Policy.bind("BranchWizardPage.branchName")); //$NON-NLS-1$ - branchText = createTextField(composite); - branchText.addListener(SWT.Modify, new Listener() { - public void handleEvent(Event event) { - branchTag = branchText.getText(); - updateEnablement(); - updateVersionName(branchTag); - } - }); - - createLabel(composite, ""); //$NON-NLS-1$ - createLabel(composite, ""); //$NON-NLS-1$ - - final Button check = new Button(composite, SWT.CHECK); - data = new GridData(); - data.horizontalSpan = 2; - check.setLayoutData(data); - check.setText(Policy.bind("BranchWizardPage.startWorking")); //$NON-NLS-1$ - check.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event event) { - update = check.getSelection(); - } - }); - check.setSelection(true); - update = true; - - createLabel(composite, ""); //$NON-NLS-1$ - createLabel(composite, ""); //$NON-NLS-1$ - - label = new Label(composite, SWT.WRAP); - label.setText(Policy.bind("BranchWizardPage.specifyVersion")); //$NON-NLS-1$ - data = new GridData(); - data.horizontalSpan = 2; - data.widthHint = 350; - label.setLayoutData(data); - - createLabel(composite, Policy.bind("BranchWizardPage.versionName")); //$NON-NLS-1$ - versionText = createTextField(composite); - versionText.addListener(SWT.Modify, new Listener() { - public void handleEvent(Event event) { - versionTag = versionText.getText(); - updateEnablement(); - } - }); - - if(allStickyResources) { - versionText.setEditable(false); - versionText.setText(versionName); - } - - branchText.setFocus(); - setControl(composite); - updateEnablement(); - } - - public String getBranchTag() { - return branchTag; - } - - public boolean getUpdate() { - return update; - } - - public String getVersionTag() { - return versionTag; - } - - private void updateVersionName(String branchName) { - if(versionText!=null && !allStickyResources) { - versionText.setText(Policy.bind("BranchWizardPage.versionPrefix") + branchName); //$NON-NLS-1$ - } - } - - private void updateEnablement() { - boolean complete = true; - String branch = branchText.getText(); - - if (branch.length() == 0) { - setMessage(null); - complete = false; - } else { - IStatus status = CVSTag.validateTagName(branch); - if (!status.isOK()) { - setMessage(Policy.bind("BranchWizard.branchNameWarning", status.getMessage()), WARNING); //$NON-NLS-1$ - complete = false; - } else { - if(versionText!=null) { - status = CVSTag.validateTagName(versionText.getText()); - if (!status.isOK()) { - setMessage(Policy.bind("BranchWizard.versionNameWarning", status.getMessage()), WARNING); //$NON-NLS-1$ - complete = false; - } else { - if(versionText.getText().equals(branch)) { - setMessage(Policy.bind("BranchWizard.branchAndVersionMustBeDifferent"), WARNING); //$NON-NLS-1$ - complete = false; - } - } - } - } - } - if(complete) { - setMessage(null); - } - setPageComplete(complete); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSWizardPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSWizardPage.java index b9b299c65..96983ae56 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSWizardPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSWizardPage.java @@ -110,7 +110,7 @@ public abstract class CVSWizardPage extends WizardPage { * @param text the text for the new label * @return the new label */ - protected Label createLabel(Composite parent, String text) { + public static Label createLabel(Composite parent, String text) { return createIndentedLabel(parent, text, 0); } /** @@ -122,7 +122,7 @@ public abstract class CVSWizardPage extends WizardPage { * @param indent the indent in pixels, or 0 for none * @return the new label */ - protected Label createIndentedLabel(Composite parent, String text, int indent) { + public static Label createIndentedLabel(Composite parent, String text, int indent) { Label label = new Label(parent, SWT.LEFT); label.setText(text); GridData data = new GridData(); @@ -160,7 +160,7 @@ public abstract class CVSWizardPage extends WizardPage { * @param parent the parent of the new text field * @return the new text field */ - protected Text createTextField(Composite parent) { + static public Text createTextField(Composite parent) { Text text = new Text(parent, SWT.SINGLE | SWT.BORDER); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.verticalAlignment = GridData.CENTER; |