Object x = ((IStructuredSelection)cmbPalette.getSelection()).getFirstElement();
if (x instanceof BrewerPalette){
BrewerPalette palette = (BrewerPalette) ((IStructuredSelection)cmbPalette.getSelection()).getFirstElement();
getCurrentSelection().setColorPalette(palette, reverseColors);
}else if (x instanceof PredefinedColorRule){
ColorMap cm = ((PredefinedColorRule)x).getColorMap();
if (cm != null && getCurrentSelection() != null){
//flip colors
if (reverseColors){
ColorMap reverse = new ColorMapImpl();
for (int i = 0; i < cm.getColorMapEntries().length; i ++){
ColorMapEntry entry = cm.getColorMapEntries()[i];
ColorMapEntry clone = new ColorMapEntryImpl();
clone.setColor(cm.getColorMapEntry(cm.getColorMapEntries().length - 1 - i).getColor());
clone.setLabel(entry.getLabel());
clone.setQuantity(entry.getQuantity());
clone.setOpacity(entry.getOpacity());
reverse.addColorMapEntry(clone);
}
cm = reverse;
}
getCurrentSelection().init(cm);
}
}
}
}
});
Label lblSep = new Label(linkPnl, SWT.SEPARATOR | SWT.VERTICAL);
GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false);
gd.heightHint = 10;
lblSep.setLayoutData(gd);
lnk = new Link(linkPnl, SWT.NONE);
lnk.setText("<a>" + Messages.SingleBandEditorPage_FormatExportLink + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$
lnk.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
getFormat();
}
});
Link lnk2 = new Link(linkPnl, SWT.NONE);
lnk2.setText("<a>" + Messages.SingleBandEditorPage_OneClickExportLink + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$
lnk2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false));
lnk2.setToolTipText(Messages.SingleBandEditorPage_OneClickTooltip);
lnk2.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
oneClickExport();
}
});
cmbThemingStyle.getCombo().addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
IColorMapTypePanel panel = getCurrentSelection();
if (panel != null){
((StackLayout)tableComp.getLayout()).topControl = stacks.get(panel);
tableComp.layout();
btnTest.setText(panel.getComputeValuesLabel());
btnTest.getParent().layout();
Object x = ((IStructuredSelection)cmbPalette.getSelection()).getFirstElement();;
if (x instanceof BrewerPalette){
BrewerPalette palette = (BrewerPalette) x;
getCurrentSelection().setInitialColorPalette(palette);
}else if (x instanceof PredefinedColorRule){
ColorMap cm = ((PredefinedColorRule)x).getColorMap();
if (cm != null && getCurrentSelection() != null){
getCurrentSelection().init(cm);
}
}
}
}
});
cmbPalette.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
Object x = ((IStructuredSelection)cmbPalette.getSelection()).getFirstElement();;
if (x instanceof BrewerPalette){
BrewerPalette palette = (BrewerPalette) x;
if (getCurrentSelection() != null){
getCurrentSelection().setColorPalette(palette, reverseColors);
}
}else if (x instanceof PredefinedColorRule){
ColorMap cm = ((PredefinedColorRule)x).getColorMap();
if (cm != null && getCurrentSelection() != null){
getCurrentSelection().init(cm);
}
}