use of org.eclipse.jface.viewers.ListViewer in project tdi-studio-se by Talend.
the class LoginProjectPage method instantiateControl.
@Override
public void instantiateControl(Composite container) {
/**
* 1. Create all the control first
*/
//$NON-NLS-1$
String execute = Messages.getString("LoginProjectPage.execute");
// Image openImage = ImageProvider.getImage(ERepositoryImages.OPEN_PROJECT_ICON);
// Connection Area
title = new Label(container, SWT.NONE);
title.setFont(LoginDialogV2.fixedFont);
//$NON-NLS-1$
title.setText(Messages.getString("LoginProjectPage.title"));
connectionManageArea = new Composite(container, SWT.NONE);
connectionsViewer = new ComboViewer(connectionManageArea, SWT.READ_ONLY);
connectionsViewer.getControl().setFont(LoginDialogV2.fixedFont);
manageButton = new Button(connectionManageArea, SWT.NONE);
manageButton.setFont(LoginDialogV2.fixedFont);
manageButton.setBackground(backgroundColor);
//$NON-NLS-1$
manageButton.setText(Messages.getString("LoginProjectPage.manage"));
// Project Operation Area
projectOperationArea = new Composite(container, SWT.NONE);
// Existing Project Area
selectExistingProject = new Button(projectOperationArea, SWT.RADIO);
selectExistingProject.setFont(LoginDialogV2.fixedFont);
selectExistingProject.setBackground(backgroundColor);
//$NON-NLS-1$
selectExistingProject.setText(Messages.getString("LoginProjectPage.selectProject"));
projectListArea = new Composite(projectOperationArea, SWT.NONE);
projectViewer = new ListViewer(projectListArea, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
projectViewer.getControl().setFont(LoginDialogV2.fixedFont);
projectViewer.setContentProvider(ArrayContentProvider.getInstance());
projectViewer.setLabelProvider(new ProjectLabelProvider());
projectViewer.setSorter(new ViewerSorter());
// Branch Area
branchArea = new Composite(projectListArea, SWT.NONE);
branchLabel = new Label(branchArea, SWT.NONE);
branchLabel.setFont(LoginDialogV2.fixedFont);
//$NON-NLS-1$
branchLabel.setText(Messages.getString("LoginProjectPage.Branch"));
branchesViewer = new ComboViewer(branchArea, SWT.READ_ONLY);
branchesViewer.getControl().setFont(LoginDialogV2.fixedFont);
branchesViewer.setContentProvider(ArrayContentProvider.getInstance());
branchesViewer.setLabelProvider(new LabelProvider());
refreshProjectButton = new Button(branchArea, SWT.NONE);
refreshProjectButton.setFont(LoginDialogV2.fixedFont);
refreshProjectButton.setBackground(backgroundColor);
refreshProjectButton.setImage(ImageProvider.getImage(EImage.REFRESH_ICON));
// Create New Project
createNewProject = new Button(projectOperationArea, SWT.RADIO);
createNewProject.setFont(LoginDialogV2.fixedFont);
createNewProject.setBackground(backgroundColor);
//$NON-NLS-1$
createNewProject.setText(Messages.getString("LoginProjectPage.createNewProject"));
newProjectName = new Text(projectOperationArea, SWT.BORDER);
newProjectName.setFont(LoginDialogV2.fixedFont);
newProjectName.setBackground(backgroundColor);
executeCreateNewProject = new Button(projectOperationArea, SWT.NONE);
executeCreateNewProject.setFont(LoginDialogV2.fixedFont);
//$NON-NLS-1$
executeCreateNewProject.setText(Messages.getString("LoginProjectPage.create"));
executeCreateNewProject.setBackground(backgroundColor);
// Import Demo Project
importDemoProject = new Button(projectOperationArea, SWT.RADIO);
importDemoProject.setFont(LoginDialogV2.fixedFont);
importDemoProject.setBackground(backgroundColor);
//$NON-NLS-1$
importDemoProject.setText(Messages.getString("LoginProjectPage.importDemoProject"));
executeImportDemoProject = new Button(projectOperationArea, SWT.NONE);
executeImportDemoProject.setFont(LoginDialogV2.fixedFont);
// executeImportDemoProject.setImage(openImage);
executeImportDemoProject.setText(execute);
executeImportDemoProject.setBackground(backgroundColor);
// Import Local Project
importLocalProject = new Button(projectOperationArea, SWT.RADIO);
importLocalProject.setFont(LoginDialogV2.fixedFont);
importLocalProject.setBackground(backgroundColor);
//$NON-NLS-1$
importLocalProject.setText(Messages.getString("LoginProjectPage.importLocalProject"));
executeImportLocalProject = new Button(projectOperationArea, SWT.NONE);
executeImportLocalProject.setFont(LoginDialogV2.fixedFont);
// executeImportLocalProject.setImage(openImage);
executeImportLocalProject.setText(execute);
executeImportLocalProject.setBackground(backgroundColor);
// Create SandBox Project
createSandBoxProject = new Button(projectOperationArea, SWT.RADIO);
createSandBoxProject.setFont(LoginDialogV2.fixedFont);
createSandBoxProject.setBackground(backgroundColor);
//$NON-NLS-1$
createSandBoxProject.setText(Messages.getString("LoginProjectPage.createSandBoxProject.title"));
executeCreateSandBoxProject = new Button(projectOperationArea, SWT.NONE);
executeCreateSandBoxProject.setFont(LoginDialogV2.fixedFont);
// executeCreateSandBoxProject.setImage(openImage);
executeCreateSandBoxProject.setText(execute);
executeCreateSandBoxProject.setBackground(backgroundColor);
super.instantiateControl(container);
}
use of org.eclipse.jface.viewers.ListViewer in project tdi-studio-se by Talend.
the class SetupProcessDependenciesRoutinesDialog method createTabFolderField.
private void createTabFolderField(Composite parent) {
// tab
folder = new CTabFolder(parent, SWT.NONE);
folder.setLayoutData(new GridData(GridData.FILL_BOTH));
folder.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateButtons();
}
});
userTabItem = new CTabItem(folder, SWT.NONE);
//$NON-NLS-1$
userTabItem.setText(Messages.getString("SetupProcessDependenciesRoutinesDialog.userRoutineLabel"));
systemTabItem = new CTabItem(folder, SWT.NONE);
//$NON-NLS-1$
systemTabItem.setText(Messages.getString("SetupProcessDependenciesRoutinesDialog.systemRoutineLabel"));
folder.setSelection(userTabItem);
folder.setSimple(false);
ISelectionChangedListener listListener = new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
updateButtons();
}
};
// user
Composite userComposite = new Composite(folder, SWT.NONE);
userComposite.setLayout(new GridLayout());
userComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
userViewer = new ListViewer(userComposite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
userViewer.setLabelProvider(new RoutineRecordLabelProvider());
userViewer.setContentProvider(ArrayContentProvider.getInstance());
userViewer.setInput(userRoutines);
userViewer.getList().setLayoutData(new GridData(GridData.FILL_BOTH));
userViewer.addSelectionChangedListener(listListener);
userTabItem.setControl(userComposite);
// system
Composite systemComposite = new Composite(folder, SWT.NONE);
systemComposite.setLayout(new GridLayout());
systemComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
systemViewer = new ListViewer(systemComposite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
systemViewer.setLabelProvider(new RoutineRecordLabelProvider());
systemViewer.setContentProvider(ArrayContentProvider.getInstance());
systemViewer.setInput(systemRoutines);
systemViewer.getList().setLayoutData(new GridData(GridData.FILL_BOTH));
systemViewer.addSelectionChangedListener(listListener);
systemTabItem.setControl(systemComposite);
}
use of org.eclipse.jface.viewers.ListViewer in project tdi-studio-se by Talend.
the class SetupProcessDependenciesRoutinesDialog method createButtonField.
private void createButtonField(Composite parent) {
Composite btnComposite = new Composite(parent, SWT.NONE);
btnComposite.setLayout(new GridLayout());
GridData layoutData = new GridData(GridData.FILL_VERTICAL);
layoutData.verticalAlignment = SWT.CENTER;
btnComposite.setLayoutData(layoutData);
addBtn = new Button(btnComposite, SWT.PUSH);
addBtn.setImage(ImageProvider.getImage(EImage.ADD_ICON));
addBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ListViewer currentViewer = getCurrentViewer();
if (currentViewer == null) {
return;
}
boolean system = (currentViewer == systemViewer);
List<RoutineItemRecord> currentRecords = getCurrentRecords();
ShowRoutineItemsDialog dialog = new ShowRoutineItemsDialog(getShell(), allRoutineItems, currentRecords, system);
if (dialog.open() == Window.OK) {
Property[] selectedItems = dialog.getSelectedItems();
List<Property> needAddedItems = new ArrayList<Property>();
// filter
for (Property p : selectedItems) {
boolean found = false;
for (RoutineItemRecord record : currentRecords) {
if (system) {
found = p.getLabel().equals(record.getLabel());
} else {
found = p.getId().equals(record.getId());
}
}
if (!found) {
needAddedItems.add(p);
}
}
// create
for (Property p : needAddedItems) {
RoutineItemRecord newOne = new RoutineItemRecord();
newOne.setId(p.getId());
newOne.setLabel(p.getLabel());
newOne.setName(p.getLabel());
newOne.setVersion(p.getVersion());
currentRecords.add(newOne);
}
//
currentViewer.setInput(currentRecords);
currentViewer.refresh();
updateButtons();
}
}
});
delBtn = new Button(btnComposite, SWT.PUSH);
delBtn.setImage(ImageProvider.getImage(EImage.DELETE_ICON));
delBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ListViewer currentViewer = getCurrentViewer();
List<RoutineItemRecord> currentRecords = getCurrentRecords();
if (currentViewer != null && !((IStructuredSelection) currentViewer.getSelection()).isEmpty()) {
Iterator iterator = ((IStructuredSelection) currentViewer.getSelection()).iterator();
int index = 0;
while (iterator.hasNext()) {
Object selectedRecord = iterator.next();
if (currentRecords != null && selectedRecord != null) {
index = currentRecords.indexOf(selectedRecord);
currentRecords.remove(selectedRecord);
if (index > currentRecords.size() - 1) {
index = currentRecords.size() - 1;
} else if (index < 0) {
index = 0;
}
}
}
currentViewer.setInput(currentRecords);
currentViewer.getList().select(index);
currentViewer.refresh();
}
updateButtons();
}
});
upBtn = new Button(btnComposite, SWT.PUSH);
upBtn.setImage(ImageProvider.getImage(EImage.UP_ICON));
upBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
moveDatas(true);
}
});
downBtn = new Button(btnComposite, SWT.PUSH);
downBtn.setImage(ImageProvider.getImage(EImage.DOWN_ICON));
downBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
moveDatas(false);
}
});
}
use of org.eclipse.jface.viewers.ListViewer in project tdi-studio-se by Talend.
the class SetupProcessDependenciesRoutinesDialog method moveDatas.
private void moveDatas(boolean up) {
ListViewer viewer = getCurrentViewer();
List<RoutineItemRecord> records = getCurrentRecords();
if (viewer != null && records != null && records.size() > 1) {
int selectionIndex = viewer.getList().getSelectionIndex();
final int size = records.size();
if (selectionIndex > -1 && selectionIndex < size) {
int newIndex = selectionIndex;
RoutineItemRecord movedRecord = records.remove(selectionIndex);
if (movedRecord != null) {
if (up) {
if (selectionIndex == 0) {
newIndex = size - 1;
} else {
newIndex = selectionIndex - 1;
}
} else {
if (selectionIndex == size - 1) {
newIndex = 0;
} else {
newIndex = selectionIndex + 1;
}
}
records.add(newIndex, movedRecord);
viewer.setInput(records);
viewer.refresh();
viewer.getList().setSelection(newIndex);
}
}
}
updateButtons();
}
use of org.eclipse.jface.viewers.ListViewer 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();
}
});
}
Aggregations