use of org.tigris.subversion.subclipse.ui.actions.SVNPluginAction in project subclipse by subclipse.
the class SvnWizardCommitPage method addResourcesArea.
private void addResourcesArea(Composite composite) {
// get the toolbar actions from any contributing plug-in
final SVNPluginAction[] toolbarActions = SVNUIPlugin.getCommitDialogToolBarActions();
final SVNPluginAction[] alternateCompareActions = SVNUIPlugin.getCommitDialogCompareActions();
ResourceSelectionTree.IToolbarControlCreator toolbarControlCreator = new ResourceSelectionTree.IToolbarControlCreator() {
public void createToolbarControls(ToolBarManager toolbarManager) {
toolbarManager.add(new // $NON-NLS-1$
ControlContribution(// $NON-NLS-1$
"ignoreUnversioned") {
protected Control createControl(Composite parent) {
includeUnversionedButton = new Button(parent, SWT.CHECK);
includeUnversionedButton.setText(// $NON-NLS-1$
Policy.bind("CommitDialog.includeUnversioned"));
includeUnversionedButton.setSelection(includeUnversioned);
includeUnversionedButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
includeUnversioned = includeUnversionedButton.getSelection();
includeUnversionedAction.setChecked(includeUnversioned);
toggleIncludeUnversioned();
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
return includeUnversionedButton;
}
});
toolbarManager.add(new ControlContribution("keepLocks") {
protected Control createControl(Composite parent) {
keepLocksButton = new Button(parent, SWT.CHECK);
// $NON-NLS-1$
keepLocksButton.setText(Policy.bind("CommitDialog.keepLocks"));
keepLocksButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
keepLocks = keepLocksButton.getSelection();
keepLocksAction.setChecked(keepLocksButton.getSelection());
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
return keepLocksButton;
}
});
toolbarManager.add(new Separator());
toolbarManager.add(new ControlContribution("showCompare") {
protected Control createControl(Composite parent) {
showCompareButton = new Button(parent, SWT.TOGGLE | SWT.FLAT);
showCompareButton.setImage(// $NON-NLS-1$
SVNUIPlugin.getImage(ISVNUIConstants.IMG_SYNCPANE));
showCompareButton.setToolTipText(Policy.bind("CommitDialog.showCompare"));
showCompareButton.setSelection(showCompare);
showCompareButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
showComparePane(!showCompare);
if (showCompare) {
IStructuredSelection selection = (IStructuredSelection) resourceSelectionTree.getTreeViewer().getSelection();
if (!selection.isEmpty()) {
Object sel0 = selection.getFirstElement();
if (sel0 instanceof IFile) {
final ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor((IFile) sel0);
try {
// compare dialog
if (alternateCompareActions.length > 0) {
StructuredSelection localResourceSelection = new StructuredSelection(localResource);
for (int i = 0; i < alternateCompareActions.length; i++) {
// make sure the selection is up to date
alternateCompareActions[i].selectionChanged(localResourceSelection);
alternateCompareActions[i].run();
}
} else {
setCompareInput(new SVNLocalCompareInput(localResource, SVNRevision.BASE, true));
}
} catch (Exception e1) {
}
}
}
}
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
return showCompareButton;
}
});
// add any contributing actions from the extension point
if (toolbarActions.length > 0) {
toolbarManager.add(new Separator());
for (int i = 0; i < toolbarActions.length; i++) {
SVNPluginAction action = toolbarActions[i];
toolbarManager.add(action);
}
}
}
public int getControlCount() {
return 1;
}
};
resourceSelectionTree = new ResourceSelectionTree(composite, SWT.NONE, Policy.bind("GenerateSVNDiff.Changes"), ResourceSelectionTree.dedupeResources(resourcesToCommit), statusMap, null, true, toolbarControlCreator, // $NON-NLS-1$
syncInfoSet);
if (!resourceSelectionTree.showIncludeUnversionedButton())
includeUnversionedButton.setVisible(false);
resourceSelectionTree.setCustomOptions(getCustomOptions());
resourceSelectionTree.setRemoveFromViewValidator(new ResourceSelectionTree.IRemoveFromViewValidator() {
public boolean canRemove(ArrayList resourceList, IStructuredSelection selection) {
return removalOk(resourceList, selection);
}
public String getErrorMessage() {
return removalError;
// return Policy.bind("CommitDialog.unselectedPropChangeChildren"); //$NON-NLS-1$
}
});
resourceSelectionTree.getTreeViewer().getTree().addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
selectedResources = resourceSelectionTree.getSelectedResources();
// need to update the toolbar actions too - but we use the tree viewer's selection
IStructuredSelection selection = (IStructuredSelection) resourceSelectionTree.getTreeViewer().getSelection();
if (toolbarActions.length > 0) {
for (int i = 0; i < toolbarActions.length; i++) {
SVNPluginAction action = toolbarActions[i];
action.selectionChanged(selection);
}
}
if (showCompare) {
Object sel0 = selection.getFirstElement();
if (sel0 instanceof IFile) {
final ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor((IFile) sel0);
try {
// then call those actions instead of showing the default compare dialog
if (alternateCompareActions.length > 0) {
StructuredSelection localResourceSelection = new StructuredSelection(localResource);
for (int i = 0; i < alternateCompareActions.length; i++) {
// make sure the selection is up to date
alternateCompareActions[i].selectionChanged(localResourceSelection);
alternateCompareActions[i].run();
}
} else {
setCompareInput(new SVNLocalCompareInput(localResource, SVNRevision.BASE, true));
}
} catch (Exception e1) {
}
}
}
}
});
((CheckboxTreeViewer) resourceSelectionTree.getTreeViewer()).addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
selectedResources = resourceSelectionTree.getSelectedResources();
}
});
resourceSelectionTree.getTreeViewer().addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
Object sel0 = sel.getFirstElement();
if (sel0 instanceof IFile) {
final ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor((IFile) sel0);
try {
// then call those actions instead of showing the default compare dialog
if (alternateCompareActions.length > 0) {
StructuredSelection selection = new StructuredSelection(localResource);
for (int i = 0; i < alternateCompareActions.length; i++) {
// make sure the selection is up to date
alternateCompareActions[i].selectionChanged(selection);
alternateCompareActions[i].run();
}
} else {
setCompareInput(new SVNLocalCompareInput(localResource, SVNRevision.BASE, true));
showComparePane(true);
showCompareButton.setSelection(true);
}
} catch (Exception e1) {
}
}
}
});
if (!includeUnversioned) {
resourceSelectionTree.removeUnversioned();
}
selectedResources = resourceSelectionTree.getSelectedResources();
setPageComplete(canFinish());
}
use of org.tigris.subversion.subclipse.ui.actions.SVNPluginAction in project subclipse by subclipse.
the class SVNUIPlugin method getCommitDialogCompareActions.
/**
* Returns the commit dialog compare actions found from the extension point.
*/
public static SVNPluginAction[] getCommitDialogCompareActions() {
if (commitDialogCompareActions == null) {
ArrayList actionsList = new ArrayList();
IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(COMMIT_DIALOG_COMPARE_ACTIONS);
for (int i = 0; i < elements.length; i++) {
SVNPluginAction action = new SVNPluginAction(elements[i]);
if (action.getDelegate() != null) {
actionsList.add(action);
}
}
commitDialogCompareActions = new SVNPluginAction[actionsList.size()];
actionsList.toArray(commitDialogCompareActions);
}
return commitDialogCompareActions;
}
use of org.tigris.subversion.subclipse.ui.actions.SVNPluginAction in project subclipse by subclipse.
the class SVNUIPlugin method getCommitDialogToolBarActions.
/**
* Returns all the commit dialog toolbar actions that were found from the extension point.
*/
public static SVNPluginAction[] getCommitDialogToolBarActions() {
if (commitDialogToolBarActions == null) {
ArrayList actionsList = new ArrayList();
IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(COMMIT_DIALOG_TOOLBAR_ACTIONS);
for (int i = 0; i < elements.length; i++) {
SVNPluginAction action = new SVNPluginAction(elements[i]);
if (action.getDelegate() != null) {
actionsList.add(action);
}
}
commitDialogToolBarActions = new SVNPluginAction[actionsList.size()];
actionsList.toArray(commitDialogToolBarActions);
}
return commitDialogToolBarActions;
}
Aggregations