use of org.eclipse.jface.viewers.ViewerComparator in project liferay-ide by liferay.
the class CustomJspPage method _createLeftPart.
private void _createLeftPart(Composite parent) {
ScrolledComposite leftContainer = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
Composite leftPart = SWTUtil.createComposite(leftContainer, 1, 1, GridData.FILL_BOTH, 0, 0);
FillLayout layout = new FillLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
leftContainer.setLayout(layout);
leftContainer.setMinSize(410, 200);
leftContainer.setExpandHorizontal(true);
leftContainer.setExpandVertical(true);
leftContainer.setContent(leftPart);
Label leftLabel = new Label(leftPart, SWT.NONE);
leftLabel.setText("6.2 Custom JSPs (double-click to compare with 6.2)");
_leftTreeViewer = new TreeViewer(leftPart, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
_leftTreeViewer.getTree().setLayoutData(gd);
_leftTreeViewer.setContentProvider(new ViewContentProvider());
_leftTreeViewer.setLabelProvider(new LeftViewLabelProvider());
_leftTreeViewer.addDoubleClickListener(new DoubleClickExpandListener(_leftTreeViewer));
_leftTreeViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
ISelection selection = event.getSelection();
File file = (File) ((ITreeSelection) selection).getFirstElement();
if (file.isDirectory()) {
return;
}
if (_is62FileFound(file)) {
String[] paths = _get62FilePaths(file);
compare(paths[0], paths[1], "6.2 original JSP", "custom JSP");
} else {
MessageDialog.openInformation(Display.getDefault().getActiveShell(), "File not found", "There is no such file in liferay 62");
}
}
});
_leftTreeViewer.setComparator(new ViewerComparator() {
@Override
public int category(Object element) {
File file = (File) element;
if (file.isDirectory()) {
return -1;
} else {
return super.category(element);
}
}
});
}
use of org.eclipse.jface.viewers.ViewerComparator in project liferay-ide by liferay.
the class SDKProjectConvertWizardPage method createProjectsList.
protected void createProjectsList(Composite workArea) {
Label title = new Label(workArea, SWT.NONE);
title.setText(Msgs.importProjectLabel);
title.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
// Composite listComposite = new Composite(workArea, SWT.NONE);
// GridLayout layout = new GridLayout();
// layout.numColumns = 2;
// layout.marginWidth = 0;
// layout.makeColumnsEqualWidth = false;
// listComposite.setLayout(layout);
// GridData gd = new GridData(GridData.GRAB_HORIZONTAL
// | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
// gd.grabExcessHorizontalSpace = true;
// gd.horizontalSpan = 3;
// listComposite.setLayoutData(gd);
projectsList = new CheckboxTreeViewer(workArea, SWT.BORDER);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1);
gridData.widthHint = new PixelConverter(projectsList.getControl()).convertWidthInCharsToPixels(25);
gridData.heightHint = new PixelConverter(projectsList.getControl()).convertHeightInCharsToPixels(10);
projectsList.getControl().setLayoutData(gridData);
projectsList.setContentProvider(new ITreeContentProvider() {
public void dispose() {
}
public Object[] getChildren(Object parentElement) {
return null;
}
public Object[] getElements(Object inputElement) {
return (Object[]) getDataModel().getProperty(SELECTED_PROJECTS);
}
public Object getParent(Object element) {
return null;
}
public boolean hasChildren(Object element) {
return false;
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
projectsList.setLabelProvider(new ProjectLabelProvider());
projectsList.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
ProjectRecord element = (ProjectRecord) event.getElement();
if (element.hasConflicts()) {
projectsList.setChecked(element, false);
}
getDataModel().setProperty(SELECTED_PROJECTS, projectsList.getCheckedElements());
setPageComplete(ListUtil.isNotEmpty(projectsList.getCheckedElements()));
}
});
projectsList.setInput(this);
projectsList.setComparator(new ViewerComparator());
}
use of org.eclipse.jface.viewers.ViewerComparator in project liferay-ide by liferay.
the class SDKProjectsImportWizardPage method createProjectsList.
protected void createProjectsList(Composite workArea) {
labelProjectsList = new Label(workArea, SWT.NONE);
labelProjectsList.setText(Msgs.importProjectsLabel);
labelProjectsList.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
projectsList = new CheckboxTreeViewer(workArea, SWT.BORDER);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
gridData.widthHint = new PixelConverter(projectsList.getControl()).convertWidthInCharsToPixels(25);
gridData.heightHint = new PixelConverter(projectsList.getControl()).convertHeightInCharsToPixels(10);
projectsList.getControl().setLayoutData(gridData);
projectsList.setContentProvider(new ITreeContentProvider() {
public void dispose() {
}
public Object[] getChildren(Object parentElement) {
return null;
}
public Object[] getElements(Object inputElement) {
return getProjectRecords();
}
public Object getParent(Object element) {
return null;
}
public boolean hasChildren(Object element) {
return false;
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
projectsList.setLabelProvider(createProjectsListLabelProvider());
projectsList.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
handleCheckStateChangedEvent(event);
}
});
projectsList.setInput(this);
projectsList.setComparator(new ViewerComparator());
createSelectionButtons(workArea);
}
use of org.eclipse.jface.viewers.ViewerComparator in project liferay-ide by liferay.
the class WorkingSetGroup method _createControl.
private void _createControl(Composite container) {
addToWorkingSetButton = new Button(container, SWT.CHECK);
GridData gd_addToWorkingSetButton = new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1);
gd_addToWorkingSetButton.verticalIndent = 12;
addToWorkingSetButton.setLayoutData(gd_addToWorkingSetButton);
addToWorkingSetButton.setSelection(true);
addToWorkingSetButton.setData("name", "addToWorkingSetButton");
addToWorkingSetButton.setText("Add project to working set");
addToWorkingSetButton.setSelection(false);
final Label workingsetLabel = new Label(container, SWT.NONE);
GridData gd_workingsetLabel = new GridData();
gd_workingsetLabel.horizontalIndent = 10;
workingsetLabel.setLayoutData(gd_workingsetLabel);
workingsetLabel.setEnabled(false);
workingsetLabel.setData("name", "workingsetLabel");
workingsetLabel.setText("Working set:");
Combo workingsetCombo = new Combo(container, SWT.READ_ONLY);
workingsetCombo.setEnabled(false);
workingsetCombo.setData("name", "workingsetCombo");
workingsetCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
_workingsetComboViewer = new ComboViewer(workingsetCombo);
_workingsetComboViewer.setContentProvider(new IStructuredContentProvider() {
public void dispose() {
}
public Object[] getElements(Object input) {
if (input instanceof IWorkingSet[]) {
return (IWorkingSet[]) input;
} else if (input instanceof List<?>) {
return new Object[] { input };
} else if (input instanceof Set<?>) {
return ((Set<?>) input).toArray();
}
return new IWorkingSet[0];
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
_workingsetComboViewer.setLabelProvider(new LabelProvider() {
public void dispose() {
_images.dispose();
super.dispose();
}
@SuppressWarnings("deprecation")
public Image getImage(Object element) {
if (element instanceof IWorkingSet) {
ImageDescriptor imageDescriptor = ((IWorkingSet) element).getImage();
if (imageDescriptor != null) {
try {
return (Image) _images.create(imageDescriptor);
} catch (DeviceResourceException dre) {
return null;
}
}
}
return super.getImage(element);
}
public String getText(Object element) {
if (element instanceof IWorkingSet) {
return ((IWorkingSet) element).getLabel();
} else if (element instanceof List<?>) {
StringBuffer sb = new StringBuffer();
for (Object o : (List<?>) element) {
if (o instanceof IWorkingSet) {
if (sb.length() > 0) {
sb.append(", ");
}
sb.append(((IWorkingSet) o).getLabel());
}
}
return sb.toString();
}
return super.getText(element);
}
private ResourceManager _images = new LocalResourceManager(JFaceResources.getResources());
});
_workingsetComboViewer.setComparator(new ViewerComparator());
final Button newWorkingSetButton = new Button(container, SWT.NONE);
newWorkingSetButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
newWorkingSetButton.setData("name", "configureButton");
newWorkingSetButton.setText("More...");
newWorkingSetButton.setEnabled(false);
newWorkingSetButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
IWorkingSetSelectionDialog dialog = workingSetManager.createWorkingSetSelectionDialog(_shell, true, _working_set_ids.toArray(new String[0]));
if (dialog.open() == Window.OK) {
IWorkingSet[] workingSets = dialog.getSelection();
selectWorkingSets(Arrays.asList(workingSets));
}
}
});
if (selectWorkingSets(_workingSets)) {
addToWorkingSetButton.setSelection(true);
workingsetLabel.setEnabled(true);
_workingsetComboViewer.getCombo().setEnabled(true);
newWorkingSetButton.setEnabled(true);
}
addToWorkingSetButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
boolean addToWorkingingSet = addToWorkingSetButton.getSelection();
workingsetLabel.setEnabled(addToWorkingingSet);
_workingsetComboViewer.getCombo().setEnabled(addToWorkingingSet);
newWorkingSetButton.setEnabled(addToWorkingingSet);
if (addToWorkingingSet) {
updateConfiguration();
} else {
_workingSets.clear();
}
}
});
_workingsetComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
updateConfiguration();
}
});
}
use of org.eclipse.jface.viewers.ViewerComparator in project jbosstools-openshift by jbosstools.
the class DeploymentConfigPage method createDataVolumeTable.
protected TableViewer createDataVolumeTable(Composite tableContainer) {
Table table = new Table(tableContainer, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
table.setLinesVisible(true);
table.setHeaderVisible(true);
this.dataViewer = new TableViewerBuilder(table, tableContainer).column(new IColumnLabelProvider<String>() {
@Override
public String getValue(String label) {
return label;
}
}).name("Container Path").align(SWT.LEFT).weight(2).minWidth(100).buildColumn().buildViewer();
dataViewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
String first = (String) e1;
String other = (String) e2;
return first.compareTo(other);
}
});
return dataViewer;
}
Aggregations