use of org.eclipse.jface.viewers.ArrayContentProvider in project translationstudio8 by heartsome.
the class ProjectSettingTMPage method createContents.
/**
* Create contents of the preference page.
* @param parent
*/
@Override
public Control createContents(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
container.setLayout(new GridLayout(1, false));
tableViewer = new TableViewer(container, SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE);
Table table = tableViewer.getTable();
table.setLinesVisible(true);
table.setHeaderVisible(true);
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
tableViewer.setContentProvider(new ArrayContentProvider());
createColumn(tableViewer);
tableViewer.setInput(curDbList);
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
DatabaseModelBean dbModel = (DatabaseModelBean) selection.getFirstElement();
if (null == dbModel) {
return;
}
if (Constants.DBTYPE_SQLITE.equals(dbModel.getDbType())) {
String path = dbModel.getItlDBLocation() + File.separator + dbModel.getDbName();
File file = new File(path);
if (!file.exists()) {
setMessage(Messages.getString("projectsetting.ProjectSettingTMPage.FileNotFound"));
return;
} else {
setMessage(Messages.getString("projectsetting.ProjectSettingTMPage.title"));
}
}
if (dbModel != null && !dbModel.isHasMatch()) {
setMessage(Messages.getString("projectsetting.ProjectSettingTMPage.msg1"));
}
}
});
Composite composite = new Composite(container, SWT.NONE);
composite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
composite.setLayout(new GridLayout(5, false));
new Label(composite, SWT.NONE);
HSDropDownButton addBtn = new HSDropDownButton(composite, SWT.NONE);
addBtn.setText(Messages.getString("projectsetting.ProjectSettingTMPage.addBtn"));
Menu addMenu = addBtn.getMenu();
MenuItem item = new MenuItem(addMenu, SWT.PUSH);
item.setText(Messages.getString("tm.dialog.addTm.DropDownButton.AddFileTm"));
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileDialog fileDialg = new FileDialog(getShell());
fileDialg.setFilterExtensions(new String[] { "*.hstm", "*.*" });
String result = fileDialg.open();
if (result == null) {
return;
}
File f = new File(result);
if (!f.exists()) {
return;
}
Map<DatabaseModelBean, String> r = null;
try {
r = Utils.convertFile2TmModel(f, false);
} catch (Exception e1) {
MessageDialog.openError(getShell(), Messages.getString("tm.dialog.addFileTm.errorTitle"), e1.getMessage());
}
if (r == null) {
return;
}
Iterator<DatabaseModelBean> it = r.keySet().iterator();
if (it.hasNext()) {
DatabaseModelBean selectedVal = it.next();
List<DatabaseModelBean> dbList = new ArrayList<DatabaseModelBean>();
dbList.add(selectedVal);
addToCurrDbList(dbList);
}
}
});
MenuItem serverItem = new MenuItem(addMenu, SWT.PUSH);
serverItem.setText(Messages.getString("tm.dialog.addTm.DropDownButton.AddServerTm"));
serverItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
TmDbManagerDialog dialog = new TmDbManagerDialog(getShell());
dialog.setDialogUseFor(TmDbManagerDialog.TYPE_DBSELECTED);
if (dialog.open() == Window.OK) {
Iterator<DatabaseModelBean> it = dialog.getHasSelectedDatabase().keySet().iterator();
List<DatabaseModelBean> dbList = new ArrayList<DatabaseModelBean>();
while (it.hasNext()) {
dbList.add(it.next());
}
addToCurrDbList(dbList);
}
}
});
Button createBtn = new Button(composite, SWT.NONE);
createBtn.setText(Messages.getString("projectsetting.ProjectSettingTMPage.createBtn"));
createBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
NewTmDbWizard wizard = new NewTmDbWizard();
ImportTmxWizardDialog dlg = new ImportTmxWizardDialog(getShell(), wizard);
if (dlg.open() == 0) {
DatabaseModelBean dbModel = wizard.getCreateDb();
List<DatabaseModelBean> dbList = new ArrayList<DatabaseModelBean>();
dbList.add(dbModel);
addToCurrDbList(dbList);
}
}
});
Button removeBtn = new Button(composite, SWT.NONE);
removeBtn.setText(Messages.getString("projectsetting.ProjectSettingTMPage.removeBtn"));
removeBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
removeForCurrDbList((IStructuredSelection) tableViewer.getSelection());
}
});
Button importTmxBtn = new Button(composite, SWT.NONE);
importTmxBtn.setText(Messages.getString("projectsetting.ProjectSettingTMPage.importTmxBtn"));
importTmxBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
Iterator<?> it = selection.iterator();
if (it.hasNext()) {
DatabaseModelBean dbModel = (DatabaseModelBean) it.next();
ImportTmxWizard wizard = new ImportTmxWizard(dbModel);
ImportTmxWizardDialog dlg = new ImportTmxWizardDialog(getShell(), wizard);
if (dlg.open() == 0) {
checkDbHashMatch(dbModel);
tableViewer.refresh();
}
// 刷新项目
ResourceUtils.refreshCurentSelectProject();
} else {
MessageDialog.openInformation(getShell(), Messages.getString("projectsetting.ProjectSettingTMPage.msgTitle"), Messages.getString("projectsetting.ProjectSettingTMPage.msg2"));
}
}
});
addBtn.setFocus();
Point addPoint = addBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
Point createPoint = createBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
Point remPoint = removeBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
Point importPoint = importTmxBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
int width = Math.max(importPoint.x, Math.max(remPoint.x, Math.max(addPoint.x, createPoint.x)));
GridData btnData = new GridData();
btnData.widthHint = width + 10;
addBtn.setLayoutData(btnData);
createBtn.setLayoutData(btnData);
removeBtn.setLayoutData(btnData);
importTmxBtn.setLayoutData(btnData);
return container;
}
use of org.eclipse.jface.viewers.ArrayContentProvider in project translationstudio8 by heartsome.
the class NewProjectWizardLanguagePage method createControl.
/**
* Create contents of the wizard.
* @param parent
*/
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
container.setLayout(new GridLayout(1, false));
// source language control
Group sourceLanguageGrp = new Group(container, SWT.NONE);
sourceLanguageGrp.setLayout(new GridLayout(1, false));
sourceLanguageGrp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
sourceLanguageGrp.setText(Messages.getString("wizard.NewProjectWizardLanguagePage.sourceLanguageGrp"));
srcLangComboViewer = new TableComboViewer(sourceLanguageGrp, SWT.READ_ONLY | SWT.BORDER);
TableCombo tableCombo = srcLangComboViewer.getTableCombo();
// set options.
tableCombo.setShowTableLines(false);
tableCombo.setShowTableHeader(false);
tableCombo.setDisplayColumnIndex(-1);
tableCombo.setShowImageWithinSelection(true);
tableCombo.setShowColorWithinSelection(false);
tableCombo.setShowFontWithinSelection(false);
tableCombo.setVisibleItemCount(20);
srcLangComboViewer.getTableCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
srcLangComboViewer.setLabelProvider(new LanguageLabelProvider());
srcLangComboViewer.setContentProvider(new ArrayContentProvider());
srcLangComboViewer.setInput(languages);
srcLangComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
srcLanguage = (Language) selection.getFirstElement();
validator.update();
}
});
// initialization remember value
String rmSrcLangCode = ps.getString(IPreferenceConstants.NEW_PROJECT_SRC_LANG);
if (rmSrcLangCode != null && !rmSrcLangCode.equals("")) {
for (Language srcLang : languages) {
if (srcLang.getCode().equals(rmSrcLangCode)) {
srcLangComboViewer.setSelection(new StructuredSelection(srcLang));
break;
}
}
}
// end source language
// target language control
Group targetLanguageGrp = new Group(container, SWT.NONE);
targetLanguageGrp.setLayout(new GridLayout(3, false));
targetLanguageGrp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
targetLanguageGrp.setText(Messages.getString("wizard.NewProjectWizardLanguagePage.targetLanguageGrp"));
targetLangControl.createControl(targetLanguageGrp);
// end Target language
setControl(container);
validator.update();
}
use of org.eclipse.jface.viewers.ArrayContentProvider in project translationstudio8 by heartsome.
the class NewProjectWizardSourceFilePage method createControl.
/**
* Create contents of the wizard.
* @param parent
*/
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
container.setLayout(new GridLayout(1, false));
setControl(container);
fileListViewer = new ListViewer(container, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI);
fileListViewer.getList().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
fileListViewer.setContentProvider(new ArrayContentProvider());
fileListViewer.setInput(srcFileList);
if (this.converterCaller != null) {
final Button btnConvert = new Button(container, SWT.CHECK);
btnConvert.setText(Messages.getString("wizard.NewProjectWizardSourceFilePage.btnConvert"));
btnConvert.setSelection(true);
isOpenConverter = true;
btnConvert.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
isOpenConverter = btnConvert.getSelection();
}
});
}
Composite composite = new Composite(container, SWT.NONE);
composite.setLayout(new GridLayout(2, false));
composite.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false, 1, 1));
Button addBtn = new Button(composite, SWT.NONE);
addBtn.setText(Messages.getString("wizard.NewProjectWizardSourceFilePage.addBtn"));
addBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileDialog dlg = new FileDialog(getShell(), SWT.MULTI);
// CONVERTEREXTENTION
String[] supExtentions = new String[] { "*.mif;*.idml;*.inx;*.xlf;*.rtf;*.po;*.properties;*.js;*.mqxlz;*.doc;*.xls;*.ppt;" + "*.docx;*.xlsx;*.pptx;*.odt;*.ods;*.odp;*.odg;*.rtf;*.sdlxliff;*.ttx;*.htm;*.html;*.txt;*.resx;*.rc;*.xml;*.txml", "*.*" };
dlg.setFilterExtensions(supExtentions);
if (dlg.open() != null) {
String[] files = dlg.getFileNames();
for (int i = 0; i < files.length; i++) {
StringBuffer buf = new StringBuffer(dlg.getFilterPath());
buf.append(File.separator);
buf.append(files[i]);
String file = buf.toString();
if (!srcFileList.contains(file)) {
srcFileList.add(file);
}
}
fileListViewer.refresh();
}
}
});
Button deleteBtn = new Button(composite, SWT.NONE);
deleteBtn.setText(Messages.getString("wizard.NewProjectWizardSourceFilePage.deleteBtn"));
deleteBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
IStructuredSelection selections = (IStructuredSelection) fileListViewer.getSelection();
Iterator<?> it = selections.iterator();
while (it.hasNext()) {
String file = (String) it.next();
srcFileList.remove(file);
}
fileListViewer.refresh();
}
});
}
use of org.eclipse.jface.viewers.ArrayContentProvider in project AutoRefactor by JnRouvignac.
the class ChooseRefactoringWizardPage method createRefactoringsTable.
private void createRefactoringsTable(Composite parent) {
tableViewer = newCheckList(parent, BORDER | H_SCROLL | CHECK | NO_FOCUS | HIDE_SELECTION);
createColumns(tableViewer);
tableViewer.setContentProvider(new ArrayContentProvider());
final List<RefactoringRule> refactorings = AllRefactoringRules.getAllRefactoringRules();
tableViewer.setInput(refactorings);
tableViewer.setCheckStateProvider(new CheckStateProvider(refactorings));
tableViewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object o1, Object o2) {
return ((RefactoringRule) o1).getName().compareTo(((RefactoringRule) o2).getName());
}
});
tableViewer.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object refactoring) {
final String filter = filterText.getText().toLowerCase();
final RefactoringRule rule = (RefactoringRule) refactoring;
final String description = rule.getDescription().toLowerCase();
final String name = rule.getName().toLowerCase();
return description.contains(filter) || name.contains(filter);
}
});
ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.NO_RECREATE);
tableViewer.setLabelProvider(new StyledCellLabelProvider() {
@Override
public void update(ViewerCell cell) {
final String filter = filterText.getText().toLowerCase();
final String name = ((RefactoringRule) cell.getElement()).getName();
cell.setText(name);
cell.setStyleRanges(getStyleRanges(name, filter));
}
private StyleRange[] getStyleRanges(String text, String filter) {
final int matchIndex = text.toLowerCase().indexOf(filter);
final int matchLength = filter.length();
if (matchIndex != -1 && matchLength != 0) {
final StyledString styledString = new StyledString(text, defaultStyler);
styledString.setStyle(matchIndex, matchLength, underlineStyler);
return styledString.getStyleRanges();
}
return null;
}
@Override
public String getToolTipText(Object refactoring) {
return ((RefactoringRule) refactoring).getDescription();
}
@Override
public Point getToolTipShift(Object object) {
return new Point(10, 20);
}
});
final Table table = tableViewer.getTable();
table.setLinesVisible(true);
tableViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
packColumns(table);
table.setFocus();
}
use of org.eclipse.jface.viewers.ArrayContentProvider in project azure-tools-for-java by Microsoft.
the class AzureSelectDockerHostPage method initUIMainContainer.
private void initUIMainContainer(Composite mainContainer) {
dockerImageNameTextField.setText(dockerImageDescription.dockerImageName);
dockerImageNameTextField.setToolTipText(AzureDockerValidationUtils.getDockerImageNameTip());
dockerImageNameTextField.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent event) {
if (AzureDockerValidationUtils.validateDockerImageName(((Text) event.getSource()).getText())) {
errDispatcher.removeMessage("dockerImageNameTextField", dockerImageNameTextField);
setErrorMessage(null);
setPageComplete(doValidate());
} else {
errDispatcher.addMessage("dockerImageNameTextField", AzureDockerValidationUtils.getDockerImageNameTip(), null, IMessageProvider.ERROR, dockerImageNameTextField);
setErrorMessage("Invalid Docker image name");
setPageComplete(false);
}
}
});
String artifactPath;
if (project != null) {
try {
String projectName = project.getName();
artifactPath = project.getLocation() + "/" + projectName + ".war";
} catch (Exception ignored) {
artifactPath = "";
}
} else {
artifactPath = "";
}
if (artifactPath == null || artifactPath.isEmpty() || !Files.isRegularFile(Paths.get(artifactPath))) {
errDispatcher.addMessage("dockerArtifactPathTextField", AzureDockerValidationUtils.getDockerArtifactPathTip(), null, IMessageProvider.ERROR, dockerArtifactPathTextField);
setErrorMessage("Invalid artifact path");
} else {
dockerArtifactPathTextField.setText(artifactPath);
}
dockerArtifactPathTextField.setToolTipText(AzureDockerValidationUtils.getDockerArtifactPathTip());
dockerArtifactPathTextField.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent event) {
if (AzureDockerValidationUtils.validateDockerArtifactPath(((Text) event.getSource()).getText())) {
errDispatcher.removeMessage("dockerArtifactPathTextField", dockerArtifactPathTextField);
String artifactFileName = new File(((Text) event.getSource()).getText()).getName();
wizard.setPredefinedDockerfileOptions(artifactFileName);
setErrorMessage(null);
setPageComplete(doValidate());
} else {
errDispatcher.addMessage("dockerArtifactPathTextField", AzureDockerValidationUtils.getDockerArtifactPathTip(), null, IMessageProvider.ERROR, dockerArtifactPathTextField);
setErrorMessage("Invalid artifact path");
setPageComplete(false);
}
}
});
dockerArtifactPathBrowseButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
FileDialog fileDialog = new FileDialog(dockerArtifactPathBrowseButton.getShell(), SWT.OPEN);
fileDialog.setText("Select Artifact .WAR or .JAR");
fileDialog.setFilterPath(System.getProperty("user.home"));
fileDialog.setFilterExtensions(new String[] { "*.war;*.jar", "*.jar", "*.*" });
String path = fileDialog.open();
if (path == null || (!path.toLowerCase().contains(".war") && !path.toLowerCase().contains(".jar"))) {
return;
}
dockerArtifactPathTextField.setText(path);
String artifactFileName = new File(path).getName();
wizard.setPredefinedDockerfileOptions(artifactFileName);
setPageComplete(doValidate());
}
});
TableViewerColumn colHostName = createTableViewerColumn(dockerHostsTableViewer, "Name", 150, 1);
colHostName.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((DockerHost) element).name;
}
});
TableViewerColumn colHostState = createTableViewerColumn(dockerHostsTableViewer, "State", 80, 2);
colHostState.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
DockerHost dockerHost = (DockerHost) element;
return dockerHost.hostVM.state != null ? dockerHost.hostVM.state.toString() : "TO_BE_CREATED";
}
});
TableViewerColumn colHostOS = createTableViewerColumn(dockerHostsTableViewer, "OS", 200, 3);
colHostOS.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((DockerHost) element).hostOSType.toString();
}
});
TableViewerColumn colHostApiUrl = createTableViewerColumn(dockerHostsTableViewer, "API URL", 250, 4);
colHostApiUrl.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((DockerHost) element).apiUrl.toString();
}
});
dockerHostsTableViewer.setContentProvider(new ArrayContentProvider());
dockerHostsList = new ArrayList<>();
dockerHostsTableViewer.setInput(dockerHostsList);
refreshDockerHostsTable(mainContainer);
if (!dockerHostsList.isEmpty()) {
if (dockerHostsTableSelection == null) {
dockerHostsTable.select(0);
dockerHostsTable.getItem(0).setChecked(true);
dockerHostsTableSelection = new DockerHostsTableSelection();
dockerHostsTableSelection.row = 0;
dockerHostsTableSelection.host = (DockerHost) dockerHostsTable.getItem(0).getData();
} else {
dockerHostsTable.select(dockerHostsTableSelection.row);
dockerHostsTable.getItem(dockerHostsTableSelection.row).setChecked(true);
}
} else {
dockerHostsTableSelection = null;
setPageComplete(false);
}
dockerHostsTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (e.detail == SWT.CHECK) {
DockerHost dockerHost = (DockerHost) ((TableItem) e.item).getData();
if (dockerHostsTableSelection == null || dockerHostsTableSelection.host != dockerHost) {
dockerHostsTableSelection = new DockerHostsTableSelection();
dockerHostsTableSelection.row = dockerHostsTable.indexOf((TableItem) e.item);
dockerHostsTableSelection.host = dockerHost;
for (TableItem tableItem : dockerHostsTable.getItems()) {
if (tableItem != ((TableItem) e.item) && tableItem.getChecked()) {
tableItem.setChecked(false);
}
}
dockerHostsTable.redraw();
} else {
dockerHostsTableSelection = null;
}
setPageComplete(doValidate());
}
}
});
dockerHostsRefreshButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
AzureDockerUIResources.updateAzureResourcesWithProgressDialog(mainContainer.getShell(), project);
refreshDockerHostsTable(mainContainer);
setPageComplete(doValidate());
sendButtonClickedTelemetry(REFRESH);
}
});
dockerHostsViewButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int idx = dockerHostsTable.getSelectionIndex();
if (idx >= 0 && dockerHostsTable.getItem(idx) != null) {
DockerHost dockerHost = (DockerHost) dockerHostsTable.getItem(dockerHostsTable.getSelectionIndex()).getData();
if (dockerHost != null) {
AzureViewDockerDialog viewDockerDialog = new AzureViewDockerDialog(mainContainer.getShell(), project, dockerHost, dockerManager);
viewDockerDialog.open();
if (viewDockerDialog.getInternalExitCode() == AzureViewDockerDialog.UPDATE_EXIT_CODE) {
if (dockerHost != null && !dockerHost.isUpdating) {
AzureDockerUIResources.updateDockerHost(PluginUtil.getParentShell(), project, new EditableDockerHost(dockerHost), dockerManager, true);
} else {
PluginUtil.displayErrorDialog(mainContainer.getShell(), "Error: Invalid Edit Selection", "The selected Docker host can not be edited at this time!");
}
}
setPageComplete(doValidate());
}
}
sendButtonClickedTelemetry(VIEW);
}
});
dockerHostsAddButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
AzureNewDockerWizard newDockerWizard = new AzureNewDockerWizard(project, dockerManager);
WizardDialog createNewDockerHostDialog = new AzureWizardDialog(mainContainer.getShell(), newDockerWizard);
if (createNewDockerHostDialog.open() == Window.OK) {
DockerHost host = newDockerWizard.getDockerHost();
dockerImageDescription.host = host;
dockerImageDescription.hasNewDockerHost = true;
dockerImageDescription.sid = host.sid;
AzureDockerPreferredSettings dockerPrefferedSettings = dockerManager.getDockerPreferredSettings();
if (dockerPrefferedSettings == null) {
dockerPrefferedSettings = new AzureDockerPreferredSettings();
}
dockerPrefferedSettings.region = host.hostVM.region;
dockerPrefferedSettings.vmSize = host.hostVM.vmSize;
dockerPrefferedSettings.vmOS = host.hostOSType.name();
dockerManager.setDockerPreferredSettings(dockerPrefferedSettings);
dockerHostsList.add(0, host);
dockerHostsTable.setEnabled(false);
dockerHostsRefreshButton.setEnabled(false);
dockerHostsAddButton.setEnabled(false);
dockerHostsDeleteButton.setEnabled(false);
dockerHostsEditButton.setEnabled(false);
dockerHostsTableViewer.refresh();
dockerHostsTable.getItem(0).setChecked(true);
dockerHostsTable.select(0);
}
setPageComplete(doValidate());
sendButtonClickedTelemetry(ADD);
}
});
dockerHostsDeleteButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
//dockerHostsList
int idx = dockerHostsTable.getSelectionIndex();
if (idx >= 0 && dockerHostsTable.getItem(idx) != null) {
DockerHost deleteHost = (DockerHost) dockerHostsTable.getItem(idx).getData();
if (deleteHost != null) {
Azure azureClient = dockerManager.getSubscriptionsMap().get(deleteHost.sid).azureClient;
int option = AzureDockerUIResources.deleteAzureDockerHostConfirmationDialog(mainContainer.getShell(), azureClient, deleteHost);
if (option != 1 && option != 2) {
if (AzureDockerUtils.DEBUG)
System.out.format("User canceled delete Docker host op: %d\n", option);
return;
}
dockerHostsList.remove(deleteHost);
if (dockerHostsTableSelection != null && dockerHostsTableSelection.row == idx) {
dockerHostsTableSelection = null;
}
dockerHostsTableViewer.refresh();
AzureDockerUIResources.deleteDockerHost(mainContainer.getShell(), project, azureClient, deleteHost, option, new Runnable() {
@Override
public void run() {
dockerManager.getDockerHostsList().remove(deleteHost);
dockerManager.refreshDockerHostDetails();
DefaultLoader.getIdeHelper().invokeLater(new Runnable() {
@Override
public void run() {
refreshDockerHostsTable(mainContainer);
}
});
}
});
}
setPageComplete(doValidate());
}
sendButtonClickedTelemetry(DELETE);
}
});
dockerHostsEditButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int idx = dockerHostsTable.getSelectionIndex();
if (idx >= 0 && dockerHostsTable.getItem(idx) != null) {
DockerHost updateHost = (DockerHost) dockerHostsTable.getItem(idx).getData();
if (updateHost != null && !updateHost.isUpdating) {
AzureDockerUIResources.updateDockerHost(PluginUtil.getParentShell(), project, new EditableDockerHost(updateHost), dockerManager, true);
} else {
PluginUtil.displayErrorDialog(mainContainer.getShell(), "Error: Invalid Edit Selection", "The selected Docker host can not be edited at this time!");
}
}
setPageComplete(doValidate());
sendButtonClickedTelemetry(EDIT);
}
});
}
Aggregations