use of org.hibernate.eclipse.console.wizards.UpDownListComposite in project jbosstools-hibernate by jbosstools.
the class ConsoleConfigurationMappingsTab method buildMappingFileTable.
private UpDownListComposite buildMappingFileTable(Composite parent) {
mappingFilesViewer = new UpDownListComposite(parent, SWT.NONE, HibernateConsoleMessages.ConsoleConfigurationMappingsTab_additional_mapping_files) {
protected Object[] handleAdd(int idx) {
TableItem[] items = getTable().getItems();
IPath[] exclude = new IPath[items.length];
for (int i = 0; i < items.length; i++) {
TableItem item = items[i];
exclude[i] = (IPath) item.getData();
}
// $NON-NLS-1$
return DialogSelectionHelper.chooseFileEntries(getShell(), null, exclude, HibernateConsoleMessages.ConsoleConfigurationMappingsTab_add_hbm_xml_file, HibernateConsoleMessages.ConsoleConfigurationMappingsTab_add_hibernate_mapping_file, new String[] { "hbm.xml" }, true, false, true);
}
protected void listChanged() {
updateLaunchConfigurationDialog();
}
};
GridData gd;
gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = 3;
gd.verticalSpan = 1;
mappingFilesViewer.setLayoutData(gd);
return mappingFilesViewer;
}
use of org.hibernate.eclipse.console.wizards.UpDownListComposite in project jbosstools-hibernate by jbosstools.
the class ExporterSettingsTab method createExporterTable.
private void createExporterTable(Composite parent) {
exporterUpDown = new UpDownListComposite(parent, SWT.NONE, HibernateConsoleMessages.ExporterSettingsTab_exporters, true, new ExporterLabelProvider(), new ExporterContentProvider()) {
protected Object[] handleAdd(int idx) {
switch(idx) {
case 0:
Object[] selectExporters = selectExporters(getShell(), HibernateConsoleMessages.ExporterSettingsTab_add_exporter, HibernateConsoleMessages.ExporterSettingsTab_select_exporter_you_want_to_add);
for (int i = 0; i < selectExporters.length; i++) {
ExporterDefinition exporterDefinition = (ExporterDefinition) selectExporters[i];
addDef(exporterDefinition);
}
// { exporterFactory };
return new Object[0];
case 1:
getExporterTable().setAllChecked(true);
selectedExporters.clear();
observableFactoryList.copyUnderlyingList(selectedExporters);
dialogChanged();
break;
case 2:
getExporterTable().setAllChecked(false);
selectedExporters.clear();
dialogChanged();
break;
default:
break;
}
return null;
}
private void addDef(ExporterDefinition expDef) {
int initialCount = getTable().getItemCount();
boolean duplicate = false;
do {
duplicate = false;
initialCount++;
for (ExporterFactory def : observableFactoryList.getList()) {
if (def.getId().equals("" + initialCount)) {
// $NON-NLS-1$
duplicate = true;
}
}
} while (duplicate);
// $NON-NLS-1$
String initialName = "" + initialCount;
ExporterFactory exporterFactory = new ExporterFactory(expDef, initialName);
observableFactoryList.add(exporterFactory);
selectedExporters.add(exporterFactory);
((CheckboxTableViewer) getTableViewer()).setChecked(exporterFactory, true);
}
@SuppressWarnings("unchecked")
protected void handleRemove() {
IStructuredSelection selection = (IStructuredSelection) getTableViewer().getSelection();
if (selection != null) {
Iterator<Object> iterator = selection.iterator();
while (iterator.hasNext()) {
Object item = iterator.next();
observableFactoryList.remove((ExporterFactory) item);
deletedExporterIds.add(((ExporterFactory) item).getId());
}
// getTableViewer().setSelection(StructuredSelection.EMPTY);
listChanged();
}
}
protected void moveSelectionDown() {
Table table = getTableViewer().getTable();
int[] indices = table.getSelectionIndices();
if (indices.length < 1) {
return;
}
int[] newSelection = new int[indices.length];
int max = table.getItemCount() - 1;
for (int i = indices.length - 1; i >= 0; i--) {
int index = indices[i];
if (index < max) {
ExporterFactory data = (ExporterFactory) getTableViewer().getElementAt(index);
observableFactoryList.moveTo(index + 1, data);
newSelection[i] = index + 1;
}
}
table.setSelection(newSelection);
listChanged();
}
protected void moveSelectionUp() {
Table table = getTableViewer().getTable();
int[] indices = table.getSelectionIndices();
int[] newSelection = new int[indices.length];
for (int i = 0; i < indices.length; i++) {
int index = indices[i];
if (index > 0) {
ExporterFactory data = (ExporterFactory) getTableViewer().getElementAt(index);
observableFactoryList.moveTo(index - 1, data);
newSelection[i] = index - 1;
}
}
table.setSelection(newSelection);
listChanged();
}
protected String[] getAddButtonLabels() {
return new String[] { HibernateConsoleMessages.ExporterSettingsTab_add, HibernateConsoleMessages.ExporterSettingsTab_select_all, HibernateConsoleMessages.ExporterSettingsTab_deselect_all };
}
protected void listChanged() {
dialogChanged();
}
};
getExporterTable().addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
ExporterFactory factory = (ExporterFactory) event.getElement();
if (!event.getChecked() && selectedExporters.contains(factory)) {
selectedExporters.remove(factory);
} else if (event.getChecked() && !selectedExporters.contains(factory)) {
selectedExporters.add(factory);
}
dialogChanged();
}
});
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.verticalAlignment = GridData.FILL;
gd.horizontalAlignment = GridData.FILL;
exporterUpDown.setLayoutData(gd);
}
Aggregations