|
|
|
|
@@ -25,19 +25,31 @@ import org.eclipse.jface.resource.JFaceResources;
|
|
|
|
|
import org.eclipse.swt.SWT;
|
|
|
|
|
import org.eclipse.swt.events.ModifyEvent;
|
|
|
|
|
import org.eclipse.swt.events.ModifyListener;
|
|
|
|
|
import org.eclipse.swt.events.SelectionAdapter;
|
|
|
|
|
import org.eclipse.swt.events.SelectionEvent;
|
|
|
|
|
import org.eclipse.swt.layout.FillLayout;
|
|
|
|
|
import org.eclipse.swt.layout.FormAttachment;
|
|
|
|
|
import org.eclipse.swt.layout.FormData;
|
|
|
|
|
import org.eclipse.swt.layout.FormLayout;
|
|
|
|
|
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.Control;
|
|
|
|
|
import org.eclipse.swt.widgets.Group;
|
|
|
|
|
import org.eclipse.swt.widgets.Label;
|
|
|
|
|
import org.eclipse.swt.widgets.Text;
|
|
|
|
|
import org.eclipse.ui.PlatformUI;
|
|
|
|
|
import org.talend.commons.exception.ExceptionHandler;
|
|
|
|
|
import org.talend.commons.ui.runtime.exception.ExceptionMessageDialog;
|
|
|
|
|
import org.talend.commons.ui.runtime.image.EImage;
|
|
|
|
|
import org.talend.commons.ui.runtime.image.ImageProvider;
|
|
|
|
|
import org.talend.core.model.general.ConnectionBean;
|
|
|
|
|
import org.talend.core.service.IStudioLiteP2Service;
|
|
|
|
|
import org.talend.core.service.IStudioLiteP2Service.UpdateSiteConfig;
|
|
|
|
|
import org.talend.repository.ProjectManager;
|
|
|
|
|
import org.talend.repository.i18n.Messages;
|
|
|
|
|
import org.talend.repository.ui.login.LoginHelper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* DOC cmeng class global comment. Detailled comment
|
|
|
|
|
@@ -50,43 +62,146 @@ public class UpdatesitePreferencePage extends PreferencePage {
|
|
|
|
|
|
|
|
|
|
private Text updateUriText;
|
|
|
|
|
|
|
|
|
|
private Text remoteReleaseUriText;
|
|
|
|
|
|
|
|
|
|
private Text remoteUpdateUriText;
|
|
|
|
|
|
|
|
|
|
private Button overwriteRemoteUpdateSettingsBtn;
|
|
|
|
|
|
|
|
|
|
private Composite panel;
|
|
|
|
|
|
|
|
|
|
private Composite remotePanel;
|
|
|
|
|
|
|
|
|
|
private Composite localPanel;
|
|
|
|
|
|
|
|
|
|
private Composite warningPanel;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected Control createContents(Composite parent) {
|
|
|
|
|
this.setTitle(Messages.getString("UpdatesitePreferencePage.title"));
|
|
|
|
|
|
|
|
|
|
Composite panel = new Composite(parent, SWT.None);
|
|
|
|
|
panel.setLayoutData(new GridData(GridData.FILL_BOTH));
|
|
|
|
|
panel = new Composite(parent, SWT.NONE);
|
|
|
|
|
panel.setLayout(new FormLayout());
|
|
|
|
|
|
|
|
|
|
GridLayout panelLayout = new GridLayout(2, false);
|
|
|
|
|
FormData fd = null;
|
|
|
|
|
remotePanel = new Composite(panel, SWT.NONE);
|
|
|
|
|
FormLayout formLayout = new FormLayout();
|
|
|
|
|
formLayout.marginBottom = 7;
|
|
|
|
|
remotePanel.setLayout(formLayout);
|
|
|
|
|
fd = new FormData();
|
|
|
|
|
fd.top = new FormAttachment(0);
|
|
|
|
|
fd.left = new FormAttachment(0);
|
|
|
|
|
fd.right = new FormAttachment(100);
|
|
|
|
|
remotePanel.setLayoutData(fd);
|
|
|
|
|
|
|
|
|
|
Group remoteGroup = null;
|
|
|
|
|
GridLayout panelLayout = null;
|
|
|
|
|
GridData gd = null;
|
|
|
|
|
ConnectionBean curConnection = LoginHelper.getInstance().getCurrentSelectedConnBean();
|
|
|
|
|
if (PlatformUI.isWorkbenchRunning() && LoginHelper.isCloudConnection(curConnection)) {
|
|
|
|
|
remoteGroup = new Group(remotePanel, SWT.NONE);
|
|
|
|
|
String projectLabel = "";
|
|
|
|
|
try {
|
|
|
|
|
projectLabel = ProjectManager.getInstance().getCurrentProject().getLabel();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
ExceptionHandler.process(e);
|
|
|
|
|
}
|
|
|
|
|
remoteGroup.setText(Messages.getString("UpdatesitePreferencePage.group.remote", projectLabel));
|
|
|
|
|
fd = new FormData();
|
|
|
|
|
fd.top = new FormAttachment(0);
|
|
|
|
|
fd.left = new FormAttachment(0);
|
|
|
|
|
fd.right = new FormAttachment(100);
|
|
|
|
|
remoteGroup.setLayoutData(fd);
|
|
|
|
|
remoteGroup.setLayout(new FillLayout());
|
|
|
|
|
|
|
|
|
|
Composite RemoteSettingsPanel = new Composite(remoteGroup, SWT.NONE);
|
|
|
|
|
RemoteSettingsPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
|
|
|
|
|
|
|
|
|
|
panelLayout = new GridLayout(2, false);
|
|
|
|
|
panelLayout.horizontalSpacing = 10;
|
|
|
|
|
panelLayout.verticalSpacing = 5;
|
|
|
|
|
RemoteSettingsPanel.setLayout(panelLayout);
|
|
|
|
|
|
|
|
|
|
Label remoteReleaseLabel = new Label(RemoteSettingsPanel, SWT.NONE);
|
|
|
|
|
remoteReleaseLabel.setText(Messages.getString("UpdatesitePreferencePage.base"));
|
|
|
|
|
gd = new GridData();
|
|
|
|
|
remoteReleaseLabel.setLayoutData(gd);
|
|
|
|
|
|
|
|
|
|
remoteReleaseUriText = new Text(RemoteSettingsPanel, SWT.BORDER);
|
|
|
|
|
remoteReleaseUriText.setEditable(false);
|
|
|
|
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
|
|
|
|
remoteReleaseUriText.setLayoutData(gd);
|
|
|
|
|
|
|
|
|
|
Label remoteUpdateLabel = new Label(RemoteSettingsPanel, SWT.NONE);
|
|
|
|
|
remoteUpdateLabel.setText(Messages.getString("UpdatesitePreferencePage.update"));
|
|
|
|
|
gd = new GridData();
|
|
|
|
|
remoteUpdateLabel.setLayoutData(gd);
|
|
|
|
|
|
|
|
|
|
remoteUpdateUriText = new Text(RemoteSettingsPanel, SWT.BORDER);
|
|
|
|
|
remoteUpdateUriText.setEditable(false);
|
|
|
|
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
|
|
|
|
remoteUpdateUriText.setLayoutData(gd);
|
|
|
|
|
|
|
|
|
|
overwriteRemoteUpdateSettingsBtn = new Button(remotePanel, SWT.CHECK);
|
|
|
|
|
overwriteRemoteUpdateSettingsBtn
|
|
|
|
|
.setText(Messages.getString("UpdatesitePreferencePage.btn.overwriteRemoteUpdateSettings"));
|
|
|
|
|
fd = new FormData();
|
|
|
|
|
fd.top = new FormAttachment(remoteGroup, 10, SWT.BOTTOM);
|
|
|
|
|
fd.left = new FormAttachment(0);
|
|
|
|
|
fd.right = new FormAttachment(100);
|
|
|
|
|
overwriteRemoteUpdateSettingsBtn.setLayoutData(fd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
localPanel = new Composite(panel, SWT.NONE);
|
|
|
|
|
localPanel.setLayout(new FormLayout());
|
|
|
|
|
fd = new FormData();
|
|
|
|
|
fd.top = new FormAttachment(remotePanel, 0, SWT.BOTTOM);
|
|
|
|
|
fd.left = new FormAttachment(0);
|
|
|
|
|
fd.right = new FormAttachment(100);
|
|
|
|
|
fd.bottom = new FormAttachment(100);
|
|
|
|
|
localPanel.setLayoutData(fd);
|
|
|
|
|
|
|
|
|
|
Group localGroup = new Group(localPanel, SWT.NONE);
|
|
|
|
|
localGroup.setText(Messages.getString("UpdatesitePreferencePage.group.local"));
|
|
|
|
|
fd = new FormData();
|
|
|
|
|
fd.top = new FormAttachment(0);
|
|
|
|
|
fd.left = new FormAttachment(0);
|
|
|
|
|
fd.right = new FormAttachment(100);
|
|
|
|
|
fd.bottom = new FormAttachment(100);
|
|
|
|
|
localGroup.setLayoutData(fd);
|
|
|
|
|
localGroup.setLayout(new FillLayout());
|
|
|
|
|
|
|
|
|
|
Composite localSettingsPanel = new Composite(localGroup, SWT.None);
|
|
|
|
|
localSettingsPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
|
|
|
|
|
|
|
|
|
|
panelLayout = new GridLayout(2, false);
|
|
|
|
|
panelLayout.horizontalSpacing = 10;
|
|
|
|
|
panelLayout.verticalSpacing = 5;
|
|
|
|
|
panel.setLayout(panelLayout);
|
|
|
|
|
localSettingsPanel.setLayout(panelLayout);
|
|
|
|
|
|
|
|
|
|
Label releaseLabel = new Label(panel, SWT.NONE);
|
|
|
|
|
Label releaseLabel = new Label(localSettingsPanel, SWT.NONE);
|
|
|
|
|
releaseLabel.setText(Messages.getString("UpdatesitePreferencePage.base"));
|
|
|
|
|
GridData gd = new GridData();
|
|
|
|
|
gd = new GridData();
|
|
|
|
|
releaseLabel.setLayoutData(gd);
|
|
|
|
|
|
|
|
|
|
releaseUriText = new Text(panel, SWT.BORDER);
|
|
|
|
|
releaseUriText = new Text(localSettingsPanel, SWT.BORDER);
|
|
|
|
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
|
|
|
|
releaseUriText.setLayoutData(gd);
|
|
|
|
|
|
|
|
|
|
Label updateLabel = new Label(panel, SWT.NONE);
|
|
|
|
|
Label updateLabel = new Label(localSettingsPanel, SWT.NONE);
|
|
|
|
|
updateLabel.setText(Messages.getString("UpdatesitePreferencePage.update"));
|
|
|
|
|
gd = new GridData();
|
|
|
|
|
updateLabel.setLayoutData(gd);
|
|
|
|
|
|
|
|
|
|
updateUriText = new Text(panel, SWT.BORDER);
|
|
|
|
|
updateUriText = new Text(localSettingsPanel, SWT.BORDER);
|
|
|
|
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
|
|
|
|
updateUriText.setLayoutData(gd);
|
|
|
|
|
|
|
|
|
|
Label placeHolder = new Label(panel, SWT.None);
|
|
|
|
|
Label placeHolder = new Label(localSettingsPanel, SWT.None);
|
|
|
|
|
gd = new GridData();
|
|
|
|
|
placeHolder.setLayoutData(gd);
|
|
|
|
|
|
|
|
|
|
warningPanel = new Composite(panel, SWT.None);
|
|
|
|
|
warningPanel = new Composite(localSettingsPanel, SWT.None);
|
|
|
|
|
gd = new GridData(GridData.GRAB_HORIZONTAL);
|
|
|
|
|
warningPanel.setLayoutData(gd);
|
|
|
|
|
warningPanel.setLayout(new GridLayout(2, false));
|
|
|
|
|
@@ -112,13 +227,36 @@ public class UpdatesitePreferencePage extends PreferencePage {
|
|
|
|
|
warningPanel.setVisible(false);
|
|
|
|
|
IProgressMonitor monitor = new NullProgressMonitor();
|
|
|
|
|
UpdateSiteConfig config = p2Service.getUpdateSiteConfig(new NullProgressMonitor());
|
|
|
|
|
URI release = config.getRelease(monitor);
|
|
|
|
|
URI release = config.getLocalRelease(monitor);
|
|
|
|
|
releaseUriText.setText(release == null ? "" : release.toString());
|
|
|
|
|
releaseUriText.setEditable(config.isReleaseEditable());
|
|
|
|
|
if (!config.isReleaseEditable()) {
|
|
|
|
|
releaseUriText.setToolTipText(Messages.getString("UpdatesitePreferencePage.tooltip.cantEdit"));
|
|
|
|
|
}
|
|
|
|
|
Collection<URI> updates = config.getUpdates(monitor);
|
|
|
|
|
|
|
|
|
|
boolean enableTmcUpdateSettings = config.isEnableTmcUpdateSettings(monitor);
|
|
|
|
|
FormData fd = (FormData) remotePanel.getLayoutData();
|
|
|
|
|
if (enableTmcUpdateSettings) {
|
|
|
|
|
fd.height = SWT.DEFAULT;
|
|
|
|
|
|
|
|
|
|
if (remoteReleaseUriText != null) {
|
|
|
|
|
String tmcRelease = config.getTmcRelease(monitor);
|
|
|
|
|
remoteReleaseUriText.setText(tmcRelease);
|
|
|
|
|
}
|
|
|
|
|
if (remoteUpdateUriText != null) {
|
|
|
|
|
String tmcUpdate = config.getTmcUpdate(monitor);
|
|
|
|
|
remoteUpdateUriText.setText(tmcUpdate);
|
|
|
|
|
}
|
|
|
|
|
boolean overwriteTmcUpdateSettings = config.isOverwriteTmcUpdateSettings(monitor);
|
|
|
|
|
if (overwriteRemoteUpdateSettingsBtn != null) {
|
|
|
|
|
overwriteRemoteUpdateSettingsBtn.setSelection(overwriteTmcUpdateSettings);
|
|
|
|
|
localPanel.setVisible(overwriteTmcUpdateSettings);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
fd.height = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Collection<URI> updates = config.getLocalUpdates(monitor);
|
|
|
|
|
StringBuilder updateStr = new StringBuilder();
|
|
|
|
|
if (updates != null && !updates.isEmpty()) {
|
|
|
|
|
for (String uri : updates.stream().map(uri -> uri.toString()).collect(Collectors.toList())) {
|
|
|
|
|
@@ -133,6 +271,8 @@ public class UpdatesitePreferencePage extends PreferencePage {
|
|
|
|
|
if (!config.isUpdateEditable()) {
|
|
|
|
|
updateUriText.setToolTipText(Messages.getString("UpdatesitePreferencePage.tooltip.cantEdit"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
panel.layout();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
ExceptionHandler.process(e);
|
|
|
|
|
}
|
|
|
|
|
@@ -153,6 +293,20 @@ public class UpdatesitePreferencePage extends PreferencePage {
|
|
|
|
|
refresh();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if (overwriteRemoteUpdateSettingsBtn != null) {
|
|
|
|
|
overwriteRemoteUpdateSettingsBtn.addSelectionListener(new SelectionAdapter() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void widgetSelected(SelectionEvent e) {
|
|
|
|
|
onOverwriteRemoteUpdateSettingsBtn(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onOverwriteRemoteUpdateSettingsBtn(SelectionEvent e) {
|
|
|
|
|
localPanel.setVisible(overwriteRemoteUpdateSettingsBtn.getSelection());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@@ -163,21 +317,24 @@ public class UpdatesitePreferencePage extends PreferencePage {
|
|
|
|
|
UpdateSiteConfig config = p2Service.getUpdateSiteConfig(new NullProgressMonitor());
|
|
|
|
|
if (config.isReleaseEditable()) {
|
|
|
|
|
String release = releaseUriText.getText();
|
|
|
|
|
config.setRelease(monitor, StringUtils.isBlank(release) ? null : p2Service.toURI(release.trim()));
|
|
|
|
|
config.setLocalRelease(monitor, StringUtils.isBlank(release) ? null : p2Service.toURI(release.trim()));
|
|
|
|
|
}
|
|
|
|
|
if (config.isUpdateEditable()) {
|
|
|
|
|
String update = updateUriText.getText();
|
|
|
|
|
if (StringUtils.isBlank(update)) {
|
|
|
|
|
config.setUpdates(monitor, null);
|
|
|
|
|
config.setLocalUpdates(monitor, null);
|
|
|
|
|
} else {
|
|
|
|
|
Collection<URI> updates = new ArrayList<>();
|
|
|
|
|
String[] splits = update.split(",");
|
|
|
|
|
for (String split : splits) {
|
|
|
|
|
updates.add(p2Service.toURI(split.trim()));
|
|
|
|
|
}
|
|
|
|
|
config.setUpdates(monitor, updates);
|
|
|
|
|
config.setLocalUpdates(monitor, updates);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (overwriteRemoteUpdateSettingsBtn != null) {
|
|
|
|
|
config.overwriteTmcUpdateSettings(monitor, overwriteRemoteUpdateSettingsBtn.getSelection());
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
ExceptionMessageDialog.openError(null, Messages.getString("UpdatesitePreferencePage.err.title"),
|
|
|
|
|
e.getLocalizedMessage(), e);
|
|
|
|
|
@@ -194,15 +351,19 @@ public class UpdatesitePreferencePage extends PreferencePage {
|
|
|
|
|
if (config.isReleaseEditable() && config.isUpdateEditable()) {
|
|
|
|
|
NullProgressMonitor monitor = new NullProgressMonitor();
|
|
|
|
|
config.resetToDefault(monitor);
|
|
|
|
|
URI release = config.getRelease(monitor);
|
|
|
|
|
URI release = config.getLocalRelease(monitor);
|
|
|
|
|
releaseUriText.setText(release == null ? "" : release.toString());
|
|
|
|
|
Collection<URI> updates = config.getUpdates(monitor);
|
|
|
|
|
Collection<URI> updates = config.getLocalUpdates(monitor);
|
|
|
|
|
StringBuilder updateStr = new StringBuilder();
|
|
|
|
|
if (updates != null && !updates.isEmpty()) {
|
|
|
|
|
updateStr.append(
|
|
|
|
|
String.join(",", updates.stream().map(uri -> uri.toString()).collect(Collectors.toList())));
|
|
|
|
|
}
|
|
|
|
|
updateUriText.setText(updateStr.toString());
|
|
|
|
|
// if (this.overwriteRemoteUpdateSettingsBtn != null) {
|
|
|
|
|
// this.overwriteRemoteUpdateSettingsBtn.setSelection(config.isOverwriteTmcUpdateSettings(monitor));
|
|
|
|
|
// onOverwriteRemoteUpdateSettingsBtn(null);
|
|
|
|
|
// }
|
|
|
|
|
} else {
|
|
|
|
|
// normally it should be a dead code
|
|
|
|
|
throw new Exception(Messages.getString("UpdatesitePreferencePage.err.reset.readonly"));
|
|
|
|
|
|