1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 10:16:03 +02:00

Code streamlining.

This commit is contained in:
Sergey Prigogin 2013-05-24 11:34:26 -07:00
parent f7de7ad848
commit 2166de01db
2 changed files with 24 additions and 54 deletions

View file

@ -51,9 +51,12 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.SelectionButtonDialogFie
public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
private static final Key PREF_TODO_TASK_TAGS = getCDTCoreKey(CCorePreferenceConstants.TODO_TASK_TAGS); private static final Key PREF_TODO_TASK_TAGS = getCDTCoreKey(CCorePreferenceConstants.TODO_TASK_TAGS);
private static final Key PREF_TODO_TASK_PRIORITIES = getCDTCoreKey(CCorePreferenceConstants.TODO_TASK_PRIORITIES); private static final Key PREF_TODO_TASK_PRIORITIES = getCDTCoreKey(CCorePreferenceConstants.TODO_TASK_PRIORITIES);
private static final Key PREF_TODO_TASK_CASE_SENSITIVE = getCDTCoreKey(CCorePreferenceConstants.TODO_TASK_CASE_SENSITIVE); private static final Key PREF_TODO_TASK_CASE_SENSITIVE = getCDTCoreKey(CCorePreferenceConstants.TODO_TASK_CASE_SENSITIVE);
private static final Key[] ALL_KEYS = new Key[] {
PREF_TODO_TASK_TAGS, PREF_TODO_TASK_PRIORITIES, PREF_TODO_TASK_CASE_SENSITIVE
};
private static final String TASK_PRIORITY_HIGH = CCorePreferenceConstants.TASK_PRIORITY_HIGH; private static final String TASK_PRIORITY_HIGH = CCorePreferenceConstants.TASK_PRIORITY_HIGH;
private static final String TASK_PRIORITY_NORMAL = CCorePreferenceConstants.TASK_PRIORITY_NORMAL; private static final String TASK_PRIORITY_NORMAL = CCorePreferenceConstants.TASK_PRIORITY_NORMAL;
private static final String TASK_PRIORITY_LOW = CCorePreferenceConstants.TASK_PRIORITY_LOW; private static final String TASK_PRIORITY_LOW = CCorePreferenceConstants.TASK_PRIORITY_LOW;
@ -68,32 +71,21 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
public TodoTaskLabelProvider() { public TodoTaskLabelProvider() {
} }
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
*/
@Override @Override
public Image getImage(Object element) { public Image getImage(Object element) {
return null; // JavaPluginImages.get(JavaPluginImages.IMG_OBJS_REFACTORING_INFO); return null;
} }
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
*/
@Override @Override
public String getText(Object element) { public String getText(Object element) {
return getColumnText(element, 0); return getColumnText(element, 0);
} }
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
*/
@Override @Override
public Image getColumnImage(Object element, int columnIndex) { public Image getColumnImage(Object element, int columnIndex) {
return null; return null;
} }
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
*/
@Override @Override
public String getColumnText(Object element, int columnIndex) { public String getColumnText(Object element, int columnIndex) {
TodoTask task = (TodoTask) element; TodoTask task = (TodoTask) element;
@ -114,9 +106,6 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
return ""; //$NON-NLS-1$ return ""; //$NON-NLS-1$
} }
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
*/
@Override @Override
public Font getFont(Object element) { public Font getFont(Object element) {
if (isDefaultTask((TodoTask) element)) { if (isDefaultTask((TodoTask) element)) {
@ -145,7 +134,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
public TodoTaskConfigurationBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) { public TodoTaskConfigurationBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) {
super(context, project, getKeys(), container); super(context, project, ALL_KEYS, container);
TaskTagAdapter adapter = new TaskTagAdapter(); TaskTagAdapter adapter = new TaskTagAdapter();
String[] buttons = new String[] { String[] buttons = new String[] {
@ -199,12 +188,6 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
fTodoTasksList.enableButton(IDX_DEFAULT, false); fTodoTasksList.enableButton(IDX_DEFAULT, false);
} }
private static Key[] getKeys() {
return new Key[] {
PREF_TODO_TASK_TAGS, PREF_TODO_TASK_PRIORITIES, PREF_TODO_TASK_CASE_SENSITIVE
};
}
public class TaskTagAdapter implements IListAdapter<TodoTask>, IDialogFieldListener { public class TaskTagAdapter implements IListAdapter<TodoTask>, IDialogFieldListener {
private boolean canEdit(List<TodoTask> selectedElements) { private boolean canEdit(List<TodoTask> selectedElements) {
return selectedElements.size() == 1; return selectedElements.size() == 1;
@ -242,37 +225,30 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
@Override @Override
protected Control createContents(Composite parent) { protected Control createContents(Composite parent) {
setShell(parent.getShell()); setShell(parent.getShell());
Composite markersComposite = createMarkersTabContent(parent);
validateSettings(null, null, null);
return markersComposite;
}
private Composite createMarkersTabContent(Composite folder) {
GridLayout layout = new GridLayout(); GridLayout layout = new GridLayout();
layout.marginHeight = 0; layout.marginHeight = 0;
layout.marginWidth = 0; layout.marginWidth = 0;
layout.numColumns = 2; layout.numColumns = 2;
PixelConverter conv = new PixelConverter(folder); PixelConverter conv = new PixelConverter(parent);
Composite markersComposite = new Composite(folder, SWT.NULL); Composite composite = new Composite(parent, SWT.NULL);
markersComposite.setLayout(layout); composite.setLayout(layout);
markersComposite.setFont(folder.getFont()); composite.setFont(parent.getFont());
GridData data = new GridData(GridData.FILL_BOTH); GridData data = new GridData(GridData.FILL_BOTH);
data.widthHint = conv.convertWidthInCharsToPixels(50); data.widthHint = conv.convertWidthInCharsToPixels(50);
Control listControl = fTodoTasksList.getListControl(markersComposite); Control listControl = fTodoTasksList.getListControl(composite);
listControl.setLayoutData(data); listControl.setLayoutData(data);
Control buttonsControl = fTodoTasksList.getButtonBox(markersComposite); Control buttonsControl = fTodoTasksList.getButtonBox(composite);
buttonsControl.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING)); buttonsControl.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING));
fCaseSensitiveCheckBox.doFillIntoGrid(markersComposite, 2); fCaseSensitiveCheckBox.doFillIntoGrid(composite, 2);
return markersComposite; validateSettings(null, null, null);
return composite;
} }
@Override @Override
@ -298,7 +274,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
return new StatusInfo(); return new StatusInfo();
} }
protected final void updateModel(DialogField field) { private void updateModel(DialogField field) {
if (field == fTodoTasksList) { if (field == fTodoTasksList) {
StringBuffer tags = new StringBuffer(); StringBuffer tags = new StringBuffer();
StringBuffer prios = new StringBuffer(); StringBuffer prios = new StringBuffer();
@ -321,9 +297,6 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
} }
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock#updateControls()
*/
@Override @Override
protected void updateControls() { protected void updateControls() {
unpackTodoTasks(); unpackTodoTasks();

View file

@ -143,7 +143,7 @@ public class TodoTaskInputDialog extends StatusDialog {
private void doValidation() { private void doValidation() {
StatusInfo status = new StatusInfo(); StatusInfo status = new StatusInfo();
String newText = fNameDialogField.getText(); String newText = fNameDialogField.getText();
if (newText.length() == 0) { if (newText.isEmpty()) {
status.setError(PreferencesMessages.TodoTaskInputDialog_error_enterName); status.setError(PreferencesMessages.TodoTaskInputDialog_error_enterName);
} else { } else {
if (newText.indexOf(',') != -1) { if (newText.indexOf(',') != -1) {
@ -157,9 +157,6 @@ public class TodoTaskInputDialog extends StatusDialog {
updateStatus(status); updateStatus(status);
} }
/*
* @see org.eclipse.jface.window.Window#configureShell(Shell)
*/
@Override @Override
protected void configureShell(Shell newShell) { protected void configureShell(Shell newShell) {
super.configureShell(newShell); super.configureShell(newShell);