use of org.eclipse.jface.viewers.ColumnLabelProvider in project AutoRefactor by JnRouvignac.
the class ChooseRefactoringWizardPage method createColumns.
private void createColumns(final TableViewer tableViewer) {
TableViewerColumn refactoringColumn = createTableViewerColumn(tableViewer);
refactoringColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((RefactoringRule) element).getName();
}
});
}
use of org.eclipse.jface.viewers.ColumnLabelProvider 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);
}
});
}
use of org.eclipse.jface.viewers.ColumnLabelProvider in project translationstudio8 by heartsome.
the class ExportTbxDialog method createColumn.
/**
* 创建Table列
* @param viewer
* ;
*/
private void createColumn(final TableViewer viewer) {
String[] clmnTitles = { Messages.getString("dialog.ExportTbxDialog.clmnTitles1"), Messages.getString("dialog.ExportTbxDialog.clmnTitles2"), Messages.getString("dialog.ExportTbxDialog.clmnTitles3"), Messages.getString("dialog.ExportTbxDialog.clmnTitles4") };
int[] clmnBounds = { 50, 80, 100, 100 };
TableViewerColumn col = createTableViewerColumn(viewer, clmnTitles[0], clmnBounds[0], 0);
col.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
ExportDatabaseBean bean = (ExportDatabaseBean) element;
return bean.getIndex();
}
});
col = createTableViewerColumn(viewer, clmnTitles[1], clmnBounds[1], 1);
col.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
ExportDatabaseBean bean = (ExportDatabaseBean) element;
return bean.getDbBean().getDbType();
}
});
col = createTableViewerColumn(viewer, clmnTitles[2], clmnBounds[2], 2);
col.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
ExportDatabaseBean bean = (ExportDatabaseBean) element;
return bean.getDbBean().getDatabaseName();
}
});
col = createTableViewerColumn(viewer, clmnTitles[3], clmnBounds[3], 3);
col.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
ExportDatabaseBean bean = (ExportDatabaseBean) element;
return bean.getExistLangs();
}
});
}
use of org.eclipse.jface.viewers.ColumnLabelProvider in project translationstudio8 by heartsome.
the class ExportTmxDialog method createColumn.
/**
* 创建Table列
* @param viewer
* ;
*/
private void createColumn(final TableViewer viewer) {
String[] clmnTitles = { Messages.getString("dialog.ExportTmxDialog.clmnTitles1"), Messages.getString("dialog.ExportTmxDialog.clmnTitles2"), Messages.getString("dialog.ExportTmxDialog.clmnTitles3"), Messages.getString("dialog.ExportTmxDialog.clmnTitles4") };
int[] clmnBounds = { 50, 80, 100, 100 };
TableViewerColumn col = createTableViewerColumn(viewer, clmnTitles[0], clmnBounds[0], 0);
col.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
ExportDatabaseBean bean = (ExportDatabaseBean) element;
return bean.getIndex();
}
});
col = createTableViewerColumn(viewer, clmnTitles[1], clmnBounds[1], 1);
col.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
ExportDatabaseBean bean = (ExportDatabaseBean) element;
return bean.getDbBean().getDbType();
}
});
col = createTableViewerColumn(viewer, clmnTitles[2], clmnBounds[2], 2);
col.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
ExportDatabaseBean bean = (ExportDatabaseBean) element;
return bean.getDbBean().getDatabaseName();
}
});
col = createTableViewerColumn(viewer, clmnTitles[3], clmnBounds[3], 3);
col.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
ExportDatabaseBean bean = (ExportDatabaseBean) element;
return bean.getExistLangs();
}
});
}
use of org.eclipse.jface.viewers.ColumnLabelProvider in project translationstudio8 by heartsome.
the class ProjectSettingTMPage method createColumn.
/**
* 创建Table列
* @param viewer
* ;
*/
private void createColumn(final TableViewer viewer) {
String[] clmnTitles = { Messages.getString("projectsetting.ProjectSettingTMPage.clmnTitles1"), Messages.getString("projectsetting.ProjectSettingTMPage.clmnTitles2"), Messages.getString("projectsetting.ProjectSettingTMPage.clmnTitles3"), Messages.getString("projectsetting.ProjectSettingTMPage.clmnTitles4"), Messages.getString("projectsetting.ProjectSettingTMPage.clmnTitles5") };
int[] clmnBounds = { 100, 100, 200, 90, 70 };
TableViewerColumn col = createTableViewerColumn(viewer, clmnTitles[0], clmnBounds[0], 0);
col.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
DatabaseModelBean dbModel = (DatabaseModelBean) element;
return dbModel.getDbName();
}
});
col = createTableViewerColumn(viewer, clmnTitles[1], clmnBounds[1], 1);
col.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
DatabaseModelBean dbModel = (DatabaseModelBean) element;
String dbType = dbModel.getDbType();
if (dbType.equals(Constants.DBTYPE_MYSQL)) {
dbType = Constants.DBTYPE_MYSQL_FOR_UI;
} else if (dbType.equals(Constants.DBTYPE_MSSQL2005)) {
dbType = Constants.DBTYPE_MSSQL2005_FOR_UI;
} else if (dbType.equals(Constants.DBTYPE_SQLITE)) {
dbType = Messages.getString("tm.dbtype.sqlite");
}
return dbType;
}
});
col = createTableViewerColumn(viewer, clmnTitles[2], clmnBounds[2], 2);
col.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
DatabaseModelBean dbModel = (DatabaseModelBean) element;
if (dbModel.getDbType().equals("Internal DB") || dbModel.getDbType().equals("SQLite")) {
return dbModel.getItlDBLocation();
}
return dbModel.getHost();
}
});
col = createTableViewerColumn(viewer, clmnTitles[3], clmnBounds[3], 3);
col.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
DatabaseModelBean dbModel = (DatabaseModelBean) element;
if (dbModel.isHasMatch()) {
return Messages.getString("projectsetting.ProjectSettingTMPage.yes");
} else {
return Messages.getString("projectsetting.ProjectSettingTMPage.no");
}
}
});
col = createTableViewerColumn(viewer, clmnTitles[4], clmnBounds[4], 4);
col.setLabelProvider(new ColumnLabelProvider() {
public Image getImage(Object element) {
DatabaseModelBean dbModel = (DatabaseModelBean) element;
if (dbModel.isDefault()) {
return checkedImage;
} else {
return uncheckedImage;
}
}
public String getText(Object element) {
return null;
}
});
col.setEditingSupport(new ReadableEditingSupport(viewer));
}
Aggregations