return Activator.getDefault().getPreferenceStore();
}
@Override
protected Control createContents(Composite parent) {
TableViewerSupport support = new TableViewerSupport(_model, parent) {
@Override
protected void initTableViewer(TableViewer viewer) {
Table table = viewer.getTable();
TableColumn col1 = new TableColumn(table, SWT.LEFT);
col1.setText("Shortcut");
col1.setWidth(100);
TableColumn col2 = new TableColumn(table, SWT.LEFT);
col2.setText("Actual Tag");
col2.setWidth(150);
TableColumn col3 = new TableColumn(table, SWT.LEFT);
col3.setText("Attributes");
col3.setWidth(200);
}
@Override
protected Object doAdd() {
TagShortcutDialog dialog = new TagShortcutDialog(getShell());
if (dialog.open() == Dialog.OK) {
return dialog.getTagShortcut();
}
return null;
}
@Override
protected void doEdit(Object obj) {
TagShortcut _tagShortcut = (TagShortcut) obj;
TagShortcutDialog dialog = new TagShortcutDialog(getShell(), _tagShortcut);
if (dialog.open() == Dialog.OK) {
TagShortcut newElement = dialog.getTagShortcut();
_tagShortcut.setShortcut(newElement.getShortcut());
_tagShortcut.setActual(newElement.getActual());
_tagShortcut.setAttributesAsString(newElement.getAttributesAsString());
}
}
@Override
protected ITableLabelProvider createLabelProvider() {
return new ITableLabelProvider() {
public Image getColumnImage(Object tagShortcut, int columnIndex) {
return null;
}
public String getColumnText(Object tagShortcut, int columnIndex) {
switch (columnIndex) {
case 0:
return ((TagShortcut) tagShortcut).getShortcut();
case 1:
return ((TagShortcut) tagShortcut).getActual();
case 2:
return ((TagShortcut) tagShortcut).getAttributesAsString();
default:
return tagShortcut.toString();
}
}
public void addListener(ILabelProviderListener listener) {
// DO NOTHING
}
public void dispose() {
// DO NOTHING
}
public boolean isLabelProperty(Object tagShortcut, String property) {
return false;
}
public void removeListener(ILabelProviderListener listener) {
// DO NOTHING
}
};
}
};
_viewer = support.getTableViewer();
_model.addAll(TagShortcut.fromPreferenceString(getPreferenceStore().getString(PreferenceConstants.TAG_SHORTCUTS_KEY)));
syncModels();
_viewer.refresh();
return support.getControl();
}