blob: dfe3c5546b4a7c7827d6a53f6945849c80e23cf9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
/*******************************************************************************
* Copyright (c) 2010 Tasktop Technologies and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tasktop Technologies - initial API and implementation
*******************************************************************************/
package org.eclipse.mylyn.commons.ui.team;
import java.util.UUID;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.DialogPage;
import org.eclipse.mylyn.commons.repositories.RepositoryLocation;
import org.eclipse.mylyn.internal.commons.repositories.InMemoryCredentialsStore;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.dialogs.PropertyPage;
/**
* @author Steffen Pingel
*/
public class RepositoryPropertyPage extends PropertyPage implements IAdaptable {
private RepositoryLocationPart part;
private RepositoryLocation workingCopy;
public RepositoryPropertyPage() {
}
@Override
protected Control createContents(Composite parent) {
initializeDialogUnits(parent);
part = new RepositoryLocationPart(getWorkingCopy());
part.setServiceLocator(this);
setControl(part.createContents(parent));
Dialog.applyDialogFont(parent);
return getControl();
}
RepositoryLocation getWorkingCopy() {
if (workingCopy == null) {
RepositoryLocation element = (RepositoryLocation) getElement().getAdapter(RepositoryLocation.class);
workingCopy = new RepositoryLocation(element);
if (workingCopy.getId() == null) {
workingCopy.setProperty(RepositoryLocation.PROPERTY_ID, UUID.randomUUID().toString());
}
workingCopy.setCredentialsStore(new InMemoryCredentialsStore(workingCopy.getCredentialsStore()));
}
return workingCopy;
}
public Object getAdapter(@SuppressWarnings("rawtypes")
Class adapter) {
if (adapter == DialogPage.class) {
return this;
}
if (adapter == IPartContainer.class) {
return this;
}
return null;
}
}
|