use of org.tigris.subversion.subclipse.ui.compare.PropertyCompareRemoteResourceNode in project subclipse by subclipse.
the class ComparePropertiesDialog method okPressed.
@Override
protected void okPressed() {
try {
if (fromWorkingCopyButton.getSelection()) {
left = new PropertyCompareLocalResourceNode(fromLocalResource, recursiveButton.getSelection(), null);
} else {
SVNRevision revision = null;
if (fromHeadButton.getSelection()) {
revision = SVNRevision.HEAD;
} else {
revision = new SVNRevision.Number(Long.parseLong(fromRevisionText.getText()));
}
RemoteFolder remoteFolder = new RemoteFolder(repository, new SVNUrl(fromRepositoryText.getText().trim()), revision);
left = new PropertyCompareRemoteResourceNode(remoteFolder, revision, recursiveButton.getSelection(), null);
}
if (toWorkingCopyButton.getSelection()) {
right = new PropertyCompareLocalResourceNode(toLocalResource, recursiveButton.getSelection(), null);
} else {
SVNRevision revision = null;
if (toHeadButton.getSelection()) {
revision = SVNRevision.HEAD;
} else {
revision = new SVNRevision.Number(Long.parseLong(toRevisionText.getText()));
}
RemoteFolder remoteFolder = new RemoteFolder(repository, new SVNUrl(toRepositoryText.getText().trim()), revision);
right = new PropertyCompareRemoteResourceNode(remoteFolder, revision, recursiveButton.getSelection(), null);
}
input = new PropertyCompareInput(left, right, recursiveButton.getSelection());
} catch (Exception e) {
MessageDialog.openError(getShell(), Policy.bind("ComparePropertiesDialog.1"), // $NON-NLS-1$
e.getMessage());
return;
}
super.okPressed();
}
use of org.tigris.subversion.subclipse.ui.compare.PropertyCompareRemoteResourceNode in project subclipse by subclipse.
the class CompareSvnPropertiesAction method execute.
public void execute(IAction action) {
exception = null;
IResource[] resources = getSelectedResources();
IPropertyProvider left = null;
right = null;
if (resources != null && resources.length > 0) {
left = new PropertyCompareLocalResourceNode(resources[0], true, null);
if (resources.length > 1) {
right = new PropertyCompareLocalResourceNode(resources[1], true, null);
} else {
final ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[0]);
BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
public void run() {
try {
right = new PropertyCompareRemoteResourceNode(svnResource.getRemoteResource(SVNRevision.HEAD), SVNRevision.HEAD, true, null);
} catch (SVNException e) {
exception = e;
}
}
});
if (exception != null) {
MessageDialog.openError(getShell(), Policy.bind("CompareSvnPropertiesAction.0"), // $NON-NLS-1$
exception.getMessage());
return;
}
}
} else {
ISVNRemoteResource[] remoteResources = getSelectedRemoteResources();
if (remoteResources != null && remoteResources.length > 0) {
left = new PropertyCompareRemoteResourceNode(remoteResources[0], SVNRevision.HEAD, true, null);
if (remoteResources.length > 1) {
right = new PropertyCompareRemoteResourceNode(remoteResources[1], SVNRevision.HEAD, true, null);
}
}
}
ComparePropertiesDialog dialog = new ComparePropertiesDialog(getShell(), left, right);
if (dialog.open() == ComparePropertiesDialog.OK) {
CompareUI.openCompareEditorOnPage(dialog.getInput(), getTargetPage());
}
}
use of org.tigris.subversion.subclipse.ui.compare.PropertyCompareRemoteResourceNode in project subclipse by subclipse.
the class ComparePropertiesDialog method createDialogArea.
protected Control createDialogArea(Composite parent) {
// $NON-NLS-1$
getShell().setText(Policy.bind("ComparePropertiesDialog.1"));
Composite composite = new Composite(parent, SWT.NULL);
composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
Group fromGroup = new Group(composite, SWT.NULL);
// $NON-NLS-1$
fromGroup.setText(Policy.bind("ShowDifferencesAsUnifiedDiffDialog.compareFrom"));
GridLayout fromLayout = new GridLayout();
fromLayout.numColumns = 3;
fromGroup.setLayout(fromLayout);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
fromGroup.setLayoutData(data);
fromWorkingCopyButton = new Button(fromGroup, SWT.RADIO);
// $NON-NLS-1$
fromWorkingCopyButton.setText(Policy.bind("ComparePropertiesDialog.2"));
fromWorkingCopyText = new Text(fromGroup, SWT.BORDER | SWT.READ_ONLY);
data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
data.widthHint = 600;
fromWorkingCopyText.setLayoutData(data);
fromWorkingCopyBrowseButton = new Button(fromGroup, SWT.PUSH);
// $NON-NLS-1$
fromWorkingCopyBrowseButton.setText(Policy.bind("ComparePropertiesDialog.3"));
fromRepositoryButton = new Button(fromGroup, SWT.RADIO);
// $NON-NLS-1$
fromRepositoryButton.setText(Policy.bind("ComparePropertiesDialog.4"));
fromRepositoryText = new Text(fromGroup, SWT.BORDER);
data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
data.widthHint = 600;
fromRepositoryText.setLayoutData(data);
fromRepositoryBrowseButton = new Button(fromGroup, SWT.PUSH);
// $NON-NLS-1$
fromRepositoryBrowseButton.setText(Policy.bind("ComparePropertiesDialog.3"));
fromHeadButton = new Button(fromGroup, SWT.CHECK);
data = new GridData();
data.horizontalSpan = 3;
fromHeadButton.setLayoutData(data);
// $NON-NLS-1$
fromHeadButton.setText(Policy.bind("ComparePropertiesDialog.6"));
fromHeadButton.setSelection(true);
Composite fromRevisionGroup = new Composite(fromGroup, SWT.NONE);
GridLayout fromRevisionLayout = new GridLayout();
fromRevisionLayout.numColumns = 3;
fromRevisionLayout.marginHeight = 0;
fromRevisionLayout.marginWidth = 0;
fromRevisionGroup.setLayout(fromRevisionLayout);
data = new GridData();
data.horizontalSpan = 3;
fromRevisionGroup.setLayoutData(data);
fromRevisionLabel = new Label(fromRevisionGroup, SWT.NONE);
// $NON-NLS-1$
fromRevisionLabel.setText(Policy.bind("ComparePropertiesDialog.7"));
fromRevisionLabel.setEnabled(false);
fromRevisionText = new Text(fromRevisionGroup, SWT.BORDER);
data = new GridData();
data.widthHint = 40;
fromRevisionText.setLayoutData(data);
fromRevisionText.setEnabled(false);
fromRevisionBrowseButton = new Button(fromRevisionGroup, SWT.PUSH);
// $NON-NLS-1$
fromRevisionBrowseButton.setText(Policy.bind("ComparePropertiesDialog.3"));
fromRevisionBrowseButton.setEnabled(false);
Group toGroup = new Group(composite, SWT.NULL);
// $NON-NLS-1$
toGroup.setText(Policy.bind("ShowDifferencesAsUnifiedDiffDialog.compareTo"));
GridLayout toLayout = new GridLayout();
toLayout.numColumns = 3;
toGroup.setLayout(toLayout);
data = new GridData(SWT.FILL, SWT.FILL, true, false);
toGroup.setLayoutData(data);
toWorkingCopyButton = new Button(toGroup, SWT.RADIO);
// $NON-NLS-1$
toWorkingCopyButton.setText(Policy.bind("ComparePropertiesDialog.2"));
toWorkingCopyText = new Text(toGroup, SWT.BORDER | SWT.READ_ONLY);
data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
data.widthHint = 600;
toWorkingCopyText.setLayoutData(data);
toWorkingCopyBrowseButton = new Button(toGroup, SWT.PUSH);
// $NON-NLS-1$
toWorkingCopyBrowseButton.setText(Policy.bind("ComparePropertiesDialog.3"));
toRepositoryButton = new Button(toGroup, SWT.RADIO);
// $NON-NLS-1$
toRepositoryButton.setText(Policy.bind("ComparePropertiesDialog.4"));
toRepositoryText = new Text(toGroup, SWT.BORDER);
data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
data.widthHint = 600;
toRepositoryText.setLayoutData(data);
toRepositoryBrowseButton = new Button(toGroup, SWT.PUSH);
// $NON-NLS-1$
toRepositoryBrowseButton.setText(Policy.bind("ComparePropertiesDialog.3"));
toHeadButton = new Button(toGroup, SWT.CHECK);
data = new GridData();
data.horizontalSpan = 3;
toHeadButton.setLayoutData(data);
// $NON-NLS-1$
toHeadButton.setText(Policy.bind("ComparePropertiesDialog.6"));
toHeadButton.setSelection(true);
Composite toRevisionGroup = new Composite(toGroup, SWT.NONE);
GridLayout toRevisionLayout = new GridLayout();
toRevisionLayout.numColumns = 3;
toRevisionLayout.marginHeight = 0;
toRevisionLayout.marginWidth = 0;
toRevisionGroup.setLayout(toRevisionLayout);
data = new GridData();
data.horizontalSpan = 3;
toRevisionGroup.setLayoutData(data);
toRevisionLabel = new Label(toRevisionGroup, SWT.NONE);
// $NON-NLS-1$
toRevisionLabel.setText(Policy.bind("ComparePropertiesDialog.7"));
toRevisionLabel.setEnabled(false);
toRevisionText = new Text(toRevisionGroup, SWT.BORDER);
data = new GridData();
data.widthHint = 40;
toRevisionText.setLayoutData(data);
toRevisionText.setEnabled(false);
toRevisionBrowseButton = new Button(toRevisionGroup, SWT.PUSH);
// $NON-NLS-1$
toRevisionBrowseButton.setText(Policy.bind("ComparePropertiesDialog.3"));
toRevisionBrowseButton.setEnabled(false);
recursiveButton = new Button(composite, SWT.CHECK);
// $NON-NLS-1$
recursiveButton.setText(Policy.bind("ComparePropertiesDialog.16"));
if (left != null) {
if (left instanceof PropertyCompareLocalResourceNode) {
fromWorkingCopyText.setText(((PropertyCompareLocalResourceNode) left).getResource().getFullPath().toString());
fromWorkingCopyButton.setSelection(true);
fromRepositoryText.setEnabled(false);
fromRepositoryBrowseButton.setEnabled(false);
fromHeadButton.setEnabled(false);
fromLocalResource = ((PropertyCompareLocalResourceNode) left).getResource();
} else if (left instanceof PropertyCompareRemoteResourceNode) {
fromRepositoryText.setText(((PropertyCompareRemoteResourceNode) left).getRemoteResource().getUrl().toString());
fromRepositoryButton.setSelection(true);
fromWorkingCopyText.setEnabled(false);
fromWorkingCopyBrowseButton.setEnabled(false);
fromHeadButton.setEnabled(true);
}
}
if (right == null) {
right = left;
}
if (right != null) {
if (right instanceof PropertyCompareLocalResourceNode) {
toWorkingCopyText.setText(((PropertyCompareLocalResourceNode) right).getResource().getFullPath().toString());
toWorkingCopyButton.setSelection(true);
toRepositoryText.setEnabled(false);
toRepositoryBrowseButton.setEnabled(false);
toHeadButton.setEnabled(false);
repository = SVNWorkspaceRoot.getSVNResourceFor(((PropertyCompareLocalResourceNode) right).getResource()).getRepository();
toLocalResource = ((PropertyCompareLocalResourceNode) right).getResource();
} else if (right instanceof PropertyCompareRemoteResourceNode) {
toRepositoryText.setText(((PropertyCompareRemoteResourceNode) right).getRemoteResource().getUrl().toString());
toRepositoryButton.setSelection(true);
toWorkingCopyText.setEnabled(false);
toWorkingCopyBrowseButton.setEnabled(false);
toHeadButton.setEnabled(true);
repository = ((PropertyCompareRemoteResourceNode) right).getRemoteResource().getRepository();
}
}
ModifyListener modifyListener = new ModifyListener() {
public void modifyText(ModifyEvent e) {
okButton.setEnabled(canFinish());
}
};
fromWorkingCopyText.addModifyListener(modifyListener);
fromRepositoryText.addModifyListener(modifyListener);
fromRevisionText.addModifyListener(modifyListener);
toWorkingCopyText.addModifyListener(modifyListener);
toRepositoryText.addModifyListener(modifyListener);
toRevisionText.addModifyListener(modifyListener);
SelectionListener selectionListener = new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (e.getSource() == fromWorkingCopyBrowseButton || e.getSource() == toWorkingCopyBrowseButton) {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider());
// $NON-NLS-1$
dialog.setTitle(Policy.bind("ComparePropertiesDialog.1"));
// $NON-NLS-1$
dialog.setMessage(Policy.bind("ComparePropertiesDialog.18"));
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
if (dialog.open() != ElementTreeSelectionDialog.CANCEL) {
Object result = dialog.getFirstResult();
if (result instanceof IResource) {
if (e.getSource() == fromWorkingCopyBrowseButton) {
fromWorkingCopyText.setText(((IResource) result).getFullPath().toString());
fromLocalResource = (IResource) result;
} else {
toWorkingCopyText.setText(((IResource) result).getFullPath().toString());
toLocalResource = (IResource) result;
}
}
}
} else if (e.getSource() == fromRepositoryBrowseButton || e.getSource() == toRepositoryBrowseButton) {
ChooseUrlDialog dialog = new ChooseUrlDialog(getShell(), null);
dialog.setRepositoryLocation(repository);
if (dialog.open() != ChooseUrlDialog.CANCEL) {
String url = dialog.getUrl();
if (url != null) {
if (e.getSource() == fromRepositoryBrowseButton) {
fromRepositoryText.setText(url);
} else {
toRepositoryText.setText(url);
}
}
}
} else if (e.getSource() == fromRevisionBrowseButton || e.getSource() == toRevisionBrowseButton) {
try {
SVNUrl url = null;
if (e.getSource() == fromRevisionBrowseButton) {
url = new SVNUrl(fromRepositoryText.getText().trim());
} else {
url = new SVNUrl(toRepositoryText.getText().trim());
}
ISVNRemoteResource remoteResource = repository.getRemoteFile(url);
HistoryDialog dialog = new HistoryDialog(getShell(), remoteResource);
if (dialog.open() != HistoryDialog.CANCEL) {
ILogEntry[] selectedEntries = dialog.getSelectedLogEntries();
if (selectedEntries.length > 0) {
if (e.getSource() == fromRevisionBrowseButton) {
fromRevisionText.setText(Long.toString(selectedEntries[selectedEntries.length - 1].getRevision().getNumber()));
} else {
toRevisionText.setText(Long.toString(selectedEntries[selectedEntries.length - 1].getRevision().getNumber()));
}
}
}
} catch (Exception exc) {
MessageDialog.openError(getShell(), Policy.bind("ComparePropertiesDialog.1"), // $NON-NLS-1$
exc.getMessage());
}
}
setEnablement();
okButton.setEnabled(canFinish());
}
};
fromWorkingCopyButton.addSelectionListener(selectionListener);
fromWorkingCopyBrowseButton.addSelectionListener(selectionListener);
fromRepositoryButton.addSelectionListener(selectionListener);
fromRepositoryBrowseButton.addSelectionListener(selectionListener);
fromHeadButton.addSelectionListener(selectionListener);
fromRevisionBrowseButton.addSelectionListener(selectionListener);
toWorkingCopyButton.addSelectionListener(selectionListener);
toWorkingCopyBrowseButton.addSelectionListener(selectionListener);
toRepositoryButton.addSelectionListener(selectionListener);
toRepositoryBrowseButton.addSelectionListener(selectionListener);
toHeadButton.addSelectionListener(selectionListener);
toRevisionBrowseButton.addSelectionListener(selectionListener);
return composite;
}
Aggregations