Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 158915 Details for
Bug 250257
persist columns in attachments table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
updated patch
patch_250257.txt (text/plain), 34.10 KB, created by
Frank Becker
on 2010-02-11 15:54:07 EST
(
hide
)
Description:
updated patch
Filename:
MIME Type:
Creator:
Frank Becker
Created:
2010-02-11 15:54:07 EST
Size:
34.10 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.tasks.ui >Index: src/org/eclipse/mylyn/internal/tasks/ui/ITasksUiPreferenceConstants.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ITasksUiPreferenceConstants.java,v >retrieving revision 1.12 >diff -u -r1.12 ITasksUiPreferenceConstants.java >--- src/org/eclipse/mylyn/internal/tasks/ui/ITasksUiPreferenceConstants.java 15 Jan 2010 02:02:58 -0000 1.12 >+++ src/org/eclipse/mylyn/internal/tasks/ui/ITasksUiPreferenceConstants.java 10 Feb 2010 22:02:49 -0000 >@@ -72,6 +72,10 @@ > > public static final String AUTO_EXPAND_TASK_LIST = "org.eclipse.mylyn.tasks.ui.auto.expand"; //$NON-NLS-1$ > >+ public static final String ATTACHMENT_SHOW_ID = "org.eclipse.mylyn.tasks.ui.attachment.showid"; //$NON-NLS-1$ >+ >+ public static final String ATTACHMENT_COLUMN_TO_STD = "org.eclipse.mylyn.tasks.ui.attachment.column.to.std"; //$NON-NLS-1$ >+ > /** > * Local subtasks are now enabled by default. > * >Index: src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java,v >retrieving revision 1.131 >diff -u -r1.131 TasksUiPlugin.java >--- src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java 5 Feb 2010 01:12:35 -0000 1.131 >+++ src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java 10 Feb 2010 22:02:49 -0000 >@@ -894,6 +894,8 @@ > > store.setDefault(ITasksUiPreferenceConstants.AUTO_EXPAND_TASK_LIST, true); > store.setDefault(ITasksUiPreferenceConstants.TASK_LIST_TOOL_TIPS_ENABLED, true); >+ store.setDefault(ITasksUiPreferenceConstants.ATTACHMENT_SHOW_ID, false); >+ store.setDefault(ITasksUiPreferenceConstants.ATTACHMENT_COLUMN_TO_STD, true); > } > > public static TaskActivityManager getTaskActivityManager() { >Index: src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentTableLabelProvider.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentTableLabelProvider.java,v >retrieving revision 1.23 >diff -u -r1.23 AttachmentTableLabelProvider.java >--- src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentTableLabelProvider.java 7 Dec 2008 03:26:58 -0000 1.23 >+++ src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentTableLabelProvider.java 10 Feb 2010 22:02:49 -0000 >@@ -46,14 +46,17 @@ > > private final AttributeEditorToolkit attributeEditorToolkit; > >- public AttachmentTableLabelProvider(TaskDataModel model, AttributeEditorToolkit attributeEditorToolkit) { >+ private final int offset; >+ >+ public AttachmentTableLabelProvider(TaskDataModel model, AttributeEditorToolkit attributeEditorToolkit, int offset) { > this.model = model; > this.attributeEditorToolkit = attributeEditorToolkit; >+ this.offset = offset; > } > > public Image getColumnImage(Object element, int columnIndex) { > ITaskAttachment attachment = (ITaskAttachment) element; >- if (columnIndex == 0) { >+ if (columnIndex + offset == 0) { > if (AttachmentUtil.isContext(attachment)) { > return CommonImages.getImage(TasksUiImages.CONTEXT_TRANSFER); > } else if (attachment.isPatch()) { >@@ -80,8 +83,16 @@ > > public String getColumnText(Object element, int columnIndex) { > ITaskAttachment attachment = (ITaskAttachment) element; >- switch (columnIndex) { >+ switch (columnIndex - offset) { > case 0: >+ String a = attachment.getUrl(); >+ int i = a.indexOf("?id="); //$NON-NLS-1$ >+ if (i != -1) { >+ return a.substring(i + 4); >+ } else { >+ return ""; //$NON-NLS-1$ >+ } >+ case 1: > if (AttachmentUtil.isContext(attachment)) { > return Messages.AttachmentTableLabelProvider_Task_Context; > } else if (attachment.isPatch()) { >@@ -89,17 +100,17 @@ > } else { > return " " + attachment.getFileName(); //$NON-NLS-1$ > } >- case 1: >- return attachment.getDescription(); > case 2: >+ return attachment.getDescription(); >+ case 3: > Long length = attachment.getLength(); > if (length < 0) { > return "-"; //$NON-NLS-1$ > } > return sizeFormatter.format(length); >- case 3: >- return (attachment.getAuthor() != null) ? attachment.getAuthor().toString() : ""; //$NON-NLS-1$ > case 4: >+ return (attachment.getAuthor() != null) ? attachment.getAuthor().toString() : ""; //$NON-NLS-1$ >+ case 5: > return (attachment.getCreationDate() != null) ? EditorUtil.formatDateTime(attachment.getCreationDate()) > : ""; //$NON-NLS-1$ > } >Index: src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java,v >retrieving revision 1.27 >diff -u -r1.27 Messages.java >--- src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java 8 Feb 2010 00:38:49 -0000 1.27 >+++ src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java 10 Feb 2010 22:02:49 -0000 >@@ -115,6 +115,8 @@ > > public static String TaskEditorAttachmentPart_Description; > >+ public static String TaskEditorAttachmentPart_Id; >+ > public static String TaskEditorAttachmentPart_Name; > > public static String TaskEditorAttachmentPart_No_attachments; >Index: src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttachmentPart.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttachmentPart.java,v >retrieving revision 1.43 >diff -u -r1.43 TaskEditorAttachmentPart.java >--- src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttachmentPart.java 6 Oct 2009 06:44:06 -0000 1.43 >+++ src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttachmentPart.java 10 Feb 2010 22:02:49 -0000 >@@ -13,28 +13,33 @@ > > package org.eclipse.mylyn.internal.tasks.ui.editors; > >+import java.io.File; > import java.util.ArrayList; > import java.util.Date; > import java.util.List; > >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.Platform; > import org.eclipse.jface.action.Action; > import org.eclipse.jface.action.IMenuListener; > import org.eclipse.jface.action.IMenuManager; > import org.eclipse.jface.action.MenuManager; > import org.eclipse.jface.action.ToolBarManager; >-import org.eclipse.jface.layout.GridDataFactory; > import org.eclipse.jface.viewers.ArrayContentProvider; > import org.eclipse.jface.viewers.ColumnViewerToolTipSupport; > import org.eclipse.jface.viewers.IOpenListener; > import org.eclipse.jface.viewers.OpenEvent; > import org.eclipse.jface.viewers.StructuredSelection; >-import org.eclipse.jface.viewers.TableViewer; > import org.eclipse.jface.viewers.Viewer; > import org.eclipse.jface.viewers.ViewerSorter; > import org.eclipse.jface.window.ToolTip; > import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages; > import org.eclipse.mylyn.internal.tasks.core.TaskAttachment; >+import org.eclipse.mylyn.internal.tasks.ui.ITasksUiPreferenceConstants; >+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; >+import org.eclipse.mylyn.internal.tasks.ui.util.ColumnState; > import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiMenus; >+import org.eclipse.mylyn.internal.tasks.ui.views.AbstractTableViewerConfigurator; > import org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard.Mode; > import org.eclipse.mylyn.tasks.core.ITaskAttachment; > import org.eclipse.mylyn.tasks.core.data.TaskAttribute; >@@ -50,7 +55,6 @@ > import org.eclipse.swt.widgets.Label; > import org.eclipse.swt.widgets.Menu; > import org.eclipse.swt.widgets.Table; >-import org.eclipse.swt.widgets.TableColumn; > import org.eclipse.ui.forms.events.ExpansionAdapter; > import org.eclipse.ui.forms.events.ExpansionEvent; > import org.eclipse.ui.forms.widgets.FormToolkit; >@@ -65,12 +69,6 @@ > > private static final String ID_POPUP_MENU = "org.eclipse.mylyn.tasks.ui.editor.menu.attachments"; //$NON-NLS-1$ > >- private final String[] attachmentsColumns = { Messages.TaskEditorAttachmentPart_Name, >- Messages.TaskEditorAttachmentPart_Description, /*"Type", */Messages.TaskEditorAttachmentPart_Size, >- Messages.TaskEditorAttachmentPart_Creator, Messages.TaskEditorAttachmentPart_Created }; >- >- private final int[] attachmentsColumnWidths = { 130, 150, /*100,*/70, 100, 100 }; >- > private List<TaskAttribute> attachments; > > private boolean hasIncoming; >@@ -79,72 +77,147 @@ > > private Composite attachmentsComposite; > >- public TaskEditorAttachmentPart() { >- setPartName(Messages.TaskEditorAttachmentPart_Attachments); >- } >+ private class AttachmentTableViewer extends AbstractTableViewerConfigurator { >+ public AttachmentTableViewer(File stateFile) { >+ super(stateFile); >+ // ignore >+ } > >- private void createAttachmentTable(FormToolkit toolkit, final Composite attachmentsComposite) { >- Table attachmentsTable = toolkit.createTable(attachmentsComposite, SWT.MULTI | SWT.FULL_SELECTION); >- attachmentsTable.setLinesVisible(true); >- attachmentsTable.setHeaderVisible(true); >- attachmentsTable.setLayout(new GridLayout()); >- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).hint(500, SWT.DEFAULT).applyTo( >- attachmentsTable); >- attachmentsTable.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER); >- >- for (int i = 0; i < attachmentsColumns.length; i++) { >- TableColumn column = new TableColumn(attachmentsTable, SWT.LEFT, i); >- column.setText(attachmentsColumns[i]); >- column.setWidth(attachmentsColumnWidths[i]); >- } >- // size column >- attachmentsTable.getColumn(2).setAlignment(SWT.RIGHT); >- >- TableViewer attachmentsViewer = new TableViewer(attachmentsTable); >- attachmentsViewer.setUseHashlookup(true); >- attachmentsViewer.setColumnProperties(attachmentsColumns); >- ColumnViewerToolTipSupport.enableFor(attachmentsViewer, ToolTip.NO_RECREATE); >+ @Override >+ protected void adjustColumInfos() { >+ boolean showAttachmentID = TasksUiPlugin.getDefault().getPreferenceStore().getBoolean( >+ ITasksUiPreferenceConstants.ATTACHMENT_SHOW_ID); >+ int idWidth = columnInfos.get(0).getWidths(); >+ if (!showAttachmentID && idWidth > 0) { >+ columnInfos.get(0).setWidths(0); >+ } else if (showAttachmentID && idWidth == 0) { >+ columnInfos.get(0).setWidths(70); >+ } > >- attachmentsViewer.setSorter(new ViewerSorter() { >- @Override >- public int compare(Viewer viewer, Object e1, Object e2) { >- ITaskAttachment attachment1 = (ITaskAttachment) e1; >- ITaskAttachment attachment2 = (ITaskAttachment) e2; >- Date created1 = attachment1.getCreationDate(); >- Date created2 = attachment2.getCreationDate(); >- if (created1 != null && created2 != null) { >- return created1.compareTo(created2); >- } else if (created1 == null && created2 != null) { >- return -1; >- } else if (created1 != null && created2 == null) { >- return 1; >- } else { >- return 0; >+ } >+ >+ @Override >+ protected void setDefaultColumnInfos() { >+ columnInfos.add(new ColumnState(Messages.TaskEditorAttachmentPart_Id, 70)); >+ columnInfos.add(new ColumnState(Messages.TaskEditorAttachmentPart_Name, 130)); >+ columnInfos.add(new ColumnState(Messages.TaskEditorAttachmentPart_Description, 150)); >+ ColumnState columnState = new ColumnState(Messages.TaskEditorAttachmentPart_Size, 70); >+ columnState.setAlignment(SWT.RIGHT); >+ columnInfos.add(columnState); >+ columnInfos.add(new ColumnState(Messages.TaskEditorAttachmentPart_Creator, 100)); >+ columnInfos.add(new ColumnState(Messages.TaskEditorAttachmentPart_Created, 100)); >+ >+ orderArray = new int[6]; >+ for (int i = 0; i < 6; i++) { >+ orderArray[i] = i; >+ } >+ >+ } >+ >+ @Override >+ protected void setupTableViewer() { >+ tableViewer.setUseHashlookup(true); >+ ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.NO_RECREATE); >+ >+ tableViewer.setSorter(new ViewerSorter() { >+ @Override >+ public int compare(Viewer viewer, Object e1, Object e2) { >+ ITaskAttachment attachment1 = (ITaskAttachment) e1; >+ ITaskAttachment attachment2 = (ITaskAttachment) e2; >+ Date created1 = attachment1.getCreationDate(); >+ Date created2 = attachment2.getCreationDate(); >+ if (created1 != null && created2 != null) { >+ return created1.compareTo(created2); >+ } else if (created1 == null && created2 != null) { >+ return -1; >+ } else if (created1 != null && created2 == null) { >+ return 1; >+ } else { >+ return 0; >+ } > } >+ }); >+ List<ITaskAttachment> attachmentList = new ArrayList<ITaskAttachment>(attachments.size()); >+ for (TaskAttribute attribute : attachments) { >+ TaskAttachment taskAttachment = new TaskAttachment(getModel().getTaskRepository(), >+ getModel().getTask(), attribute); >+ getTaskData().getAttributeMapper().updateTaskAttachment(taskAttachment, attribute); >+ attachmentList.add(taskAttachment); >+ >+ tableViewer.setContentProvider(new ArrayContentProvider()); >+ tableViewer.setLabelProvider(new AttachmentTableLabelProvider(getModel(), >+ getTaskEditorPage().getAttributeEditorToolkit(), 0)); >+ tableViewer.addOpenListener(new IOpenListener() { >+ public void open(OpenEvent event) { >+ if (!event.getSelection().isEmpty()) { >+ StructuredSelection selection = (StructuredSelection) event.getSelection(); >+ ITaskAttachment attachment = (ITaskAttachment) selection.getFirstElement(); >+ TasksUiUtil.openUrl(attachment.getUrl()); >+ } >+ } >+ }); >+ tableViewer.addSelectionChangedListener(getTaskEditorPage()); >+ tableViewer.setInput(attachmentList.toArray()); > } >- }); >+ } >+ } >+ >+ private AttachmentTableViewer attachmentsViewer; >+ >+ private boolean propertyListenerIstalled = false; > >- List<ITaskAttachment> attachmentList = new ArrayList<ITaskAttachment>(attachments.size()); >- for (TaskAttribute attribute : attachments) { >- TaskAttachment taskAttachment = new TaskAttachment(getModel().getTaskRepository(), getModel().getTask(), >- attribute); >- getTaskData().getAttributeMapper().updateTaskAttachment(taskAttachment, attribute); >- attachmentList.add(taskAttachment); >- } >- attachmentsViewer.setContentProvider(new ArrayContentProvider()); >- attachmentsViewer.setLabelProvider(new AttachmentTableLabelProvider(getModel(), >- getTaskEditorPage().getAttributeEditorToolkit())); >- attachmentsViewer.addOpenListener(new IOpenListener() { >- public void open(OpenEvent event) { >- if (!event.getSelection().isEmpty()) { >- StructuredSelection selection = (StructuredSelection) event.getSelection(); >- ITaskAttachment attachment = (ITaskAttachment) selection.getFirstElement(); >- TasksUiUtil.openUrl(attachment.getUrl()); >+ private final org.eclipse.jface.util.IPropertyChangeListener PROPERTY_LISTENER = new org.eclipse.jface.util.IPropertyChangeListener() { >+ >+ public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event) { >+ if (event.getProperty().equals(ITasksUiPreferenceConstants.ATTACHMENT_COLUMN_TO_STD)) { >+ if (TasksUiPlugin.getDefault().getPreferenceStore().getBoolean( >+ ITasksUiPreferenceConstants.ATTACHMENT_COLUMN_TO_STD)) { >+ if (attachmentsViewer != null) { >+ attachmentsViewer.resetColumnInfosToDefault(); >+ Table table = attachmentsViewer.getTable(); >+ if (!table.isDisposed()) { >+ if (TasksUiPlugin.getDefault().getPreferenceStore().getBoolean( >+ ITasksUiPreferenceConstants.ATTACHMENT_SHOW_ID)) { >+ table.getColumn(0).setWidth(70); >+ } else { >+ table.getColumn(0).setWidth(0); >+ } >+ } >+// TasksUiPlugin.getDefault().getPreferenceStore().setValue( >+// ITasksUiPreferenceConstants.ATTACHMENT_COLUMN_TO_STD, false); >+ } else { >+ IPath stateLocation = Platform.getStateLocation(TasksUiPlugin.getDefault().getBundle()); >+ File attachmentStateFile = stateLocation.append("TaskEditorAttachment.obj").toFile(); //$NON-NLS-1$ >+ attachmentStateFile.delete(); >+ } >+ } >+ } else if (event.getProperty().equals(ITasksUiPreferenceConstants.ATTACHMENT_SHOW_ID)) { >+ if (attachmentsViewer != null) { >+ Table table = attachmentsViewer.getTable(); >+ if (!table.isDisposed()) { >+ if (TasksUiPlugin.getDefault().getPreferenceStore().getBoolean( >+ ITasksUiPreferenceConstants.ATTACHMENT_SHOW_ID)) { >+ table.getColumn(0).setWidth(70); >+ } else { >+ table.getColumn(0).setWidth(0); >+ } >+// } else { >+// attachmentsViewer. >+ } > } > } >- }); >- attachmentsViewer.addSelectionChangedListener(getTaskEditorPage()); >- attachmentsViewer.setInput(attachmentList.toArray()); >+ } >+ }; >+ >+ public TaskEditorAttachmentPart() { >+ setPartName(Messages.TaskEditorAttachmentPart_Attachments); >+ } >+ >+ private void createAttachmentTable(FormToolkit toolkit, final Composite attachmentsComposite) { >+ IPath stateLocation = Platform.getStateLocation(TasksUiPlugin.getDefault().getBundle()); >+ File attachmentStateFile = stateLocation.append("TaskEditorAttachment.obj").toFile(); //$NON-NLS-1$ >+ attachmentsViewer = new AttachmentTableViewer(attachmentStateFile); >+ attachmentsViewer.create(toolkit, attachmentsComposite, 5); > > menuManager = new MenuManager(); > menuManager.setRemoveAllWhenShown(true); >@@ -154,8 +227,8 @@ > } > }); > getTaskEditorPage().getEditorSite().registerContextMenu(ID_POPUP_MENU, menuManager, attachmentsViewer, true); >- Menu menu = menuManager.createContextMenu(attachmentsTable); >- attachmentsTable.setMenu(menu); >+ Menu menu = menuManager.createContextMenu(attachmentsViewer.getTable()); >+ attachmentsViewer.getTable().setMenu(menu); > } > > private void createButtons(Composite attachmentsComposite, FormToolkit toolkit) { >@@ -230,6 +303,10 @@ > > @Override > public void dispose() { >+ if (propertyListenerIstalled) { >+ TasksUiPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(PROPERTY_LISTENER); >+ propertyListenerIstalled = false; >+ } > if (menuManager != null) { > menuManager.dispose(); > } >@@ -237,6 +314,10 @@ > } > > private void initialize() { >+ if (!propertyListenerIstalled) { >+ TasksUiPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(PROPERTY_LISTENER); >+ propertyListenerIstalled = true; >+ } > attachments = getTaskData().getAttributeMapper().getAttributesByType(getTaskData(), > TaskAttribute.TYPE_ATTACHMENT); > for (TaskAttribute attachmentAttribute : attachments) { >Index: src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties,v >retrieving revision 1.35 >diff -u -r1.35 messages.properties >--- src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties 8 Feb 2010 00:38:48 -0000 1.35 >+++ src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties 10 Feb 2010 22:02:49 -0000 >@@ -62,6 +62,7 @@ > TaskEditorAttachmentPart_Created=Created > TaskEditorAttachmentPart_Creator=Creator > TaskEditorAttachmentPart_Description=Description >+TaskEditorAttachmentPart_Id=Id > TaskEditorAttachmentPart_Name=Name > TaskEditorAttachmentPart_No_attachments=No attachments > TaskEditorAttachmentPart_Size=Size >Index: src/org/eclipse/mylyn/internal/tasks/ui/preferences/Messages.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/Messages.java,v >retrieving revision 1.4 >diff -u -r1.4 Messages.java >--- src/org/eclipse/mylyn/internal/tasks/ui/preferences/Messages.java 15 Jan 2010 02:02:58 -0000 1.4 >+++ src/org/eclipse/mylyn/internal/tasks/ui/preferences/Messages.java 10 Feb 2010 22:02:49 -0000 >@@ -108,4 +108,11 @@ > public static String Tuesday; > > public static String Wednesday; >+ >+ public static String TasksUiPreferencePage_Attachment_Table; >+ >+ public static String TasksUiPreferencePage_Attachment_Show_Id; >+ >+ public static String TasksUiPreferencePage_Attachment_Coloumn_To_Std; >+ > } >Index: src/org/eclipse/mylyn/internal/tasks/ui/preferences/TasksUiPreferencePage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/TasksUiPreferencePage.java,v >retrieving revision 1.40 >diff -u -r1.40 TasksUiPreferencePage.java >--- src/org/eclipse/mylyn/internal/tasks/ui/preferences/TasksUiPreferencePage.java 15 Jan 2010 02:02:58 -0000 1.40 >+++ src/org/eclipse/mylyn/internal/tasks/ui/preferences/TasksUiPreferencePage.java 10 Feb 2010 22:02:50 -0000 >@@ -110,6 +110,10 @@ > > private Button taskListTooltipEnabledButton; > >+ private Button attachmentShowID; >+ >+ private Button attachmentColumnUseStdWidth; >+ > public TasksUiPreferencePage() { > super(); > setPreferenceStore(TasksUiPlugin.getDefault().getPreferenceStore()); >@@ -138,6 +142,7 @@ > } > > createLinks(advanced); >+ createAttachmentTable(advanced); > updateRefreshGroupEnablements(); > applyDialogFont(container); > return container; >@@ -248,6 +253,12 @@ > // shouldn't get here > } > } >+ getPreferenceStore().setValue(ITasksUiPreferenceConstants.ATTACHMENT_SHOW_ID, attachmentShowID.getSelection()); >+ getPreferenceStore().setValue(ITasksUiPreferenceConstants.ATTACHMENT_COLUMN_TO_STD, >+ attachmentColumnUseStdWidth.getSelection()); >+ getPreferenceStore().setValue(ITasksUiPreferenceConstants.ATTACHMENT_COLUMN_TO_STD, false); >+ >+ attachmentColumnUseStdWidth.setSelection(false); > > return true; > } >@@ -289,7 +300,9 @@ > > activityTrackingEnabledButton.setSelection(MonitorUiPlugin.getDefault().getPreferenceStore().getBoolean( > MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED)); >- >+ attachmentShowID.setSelection(getPreferenceStore().getBoolean(ITasksUiPreferenceConstants.ATTACHMENT_SHOW_ID)); >+ attachmentColumnUseStdWidth.setSelection(getPreferenceStore().getBoolean( >+ ITasksUiPreferenceConstants.ATTACHMENT_COLUMN_TO_STD)); > return true; > } > >@@ -342,7 +355,10 @@ > > activityTrackingEnabledButton.setSelection(MonitorUiPlugin.getDefault().getPreferenceStore().getDefaultBoolean( > MonitorUiPlugin.ACTIVITY_TRACKING_ENABLED)); >- >+ attachmentShowID.setSelection(getPreferenceStore().getDefaultBoolean( >+ ITasksUiPreferenceConstants.ATTACHMENT_SHOW_ID)); >+ attachmentColumnUseStdWidth.setSelection(getPreferenceStore().getDefaultBoolean( >+ ITasksUiPreferenceConstants.ATTACHMENT_COLUMN_TO_STD)); > updateRefreshGroupEnablements(); > } > >@@ -631,4 +647,21 @@ > } > super.dispose(); > } >+ >+ private void createAttachmentTable(Composite parent) { >+ Group attachmentContainer = new Group(parent, SWT.SHADOW_ETCHED_IN); >+ attachmentContainer.setLayout(new GridLayout(2, false)); >+ attachmentContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ attachmentContainer.setText(Messages.TasksUiPreferencePage_Attachment_Table); >+ >+ attachmentColumnUseStdWidth = new Button(attachmentContainer, SWT.CHECK); >+ attachmentColumnUseStdWidth.setText(Messages.TasksUiPreferencePage_Attachment_Coloumn_To_Std); >+ attachmentColumnUseStdWidth.setSelection(getPreferenceStore().getBoolean( >+ ITasksUiPreferenceConstants.ATTACHMENT_COLUMN_TO_STD)); >+ >+ attachmentShowID = new Button(attachmentContainer, SWT.CHECK); >+ attachmentShowID.setText(Messages.TasksUiPreferencePage_Attachment_Show_Id); >+ attachmentShowID.setSelection(getPreferenceStore().getBoolean(ITasksUiPreferenceConstants.ATTACHMENT_SHOW_ID)); >+ >+ } > } >Index: src/org/eclipse/mylyn/internal/tasks/ui/preferences/messages.properties >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/messages.properties,v >retrieving revision 1.8 >diff -u -r1.8 messages.properties >--- src/org/eclipse/mylyn/internal/tasks/ui/preferences/messages.properties 15 Jan 2010 02:02:58 -0000 1.8 >+++ src/org/eclipse/mylyn/internal/tasks/ui/preferences/messages.properties 10 Feb 2010 22:02:50 -0000 >@@ -50,3 +50,6 @@ > Thursday= > Tuesday= > Wednesday= >+TasksUiPreferencePage_Attachment_Table=Task Editor Attachment Table >+TasksUiPreferencePage_Attachment_Show_Id=Show Attachment ID >+TasksUiPreferencePage_Attachment_Coloumn_To_Std=reset to standard Column >Index: src/org/eclipse/mylyn/internal/tasks/ui/util/ColumnState.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/ui/util/ColumnState.java >diff -N src/org/eclipse/mylyn/internal/tasks/ui/util/ColumnState.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/ui/util/ColumnState.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,75 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 Frank Becker and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Frank Becker - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.tasks.ui.util; >+ >+import java.io.Serializable; >+ >+import org.eclipse.swt.SWT; >+import org.eclipse.ui.IMemento; >+ >+public class ColumnState implements Serializable { >+ >+ private static final long serialVersionUID = 6303376618126218826L; >+ >+ private String name; >+ >+ private int widths; >+ >+ private int alignment; >+ >+ public ColumnState(String name, int widths) { >+ super(); >+ this.name = name; >+ this.widths = widths; >+ alignment = SWT.LEFT; >+ } >+ >+ public String getName() { >+ return name; >+ } >+ >+ public void setName(String name) { >+ this.name = name; >+ } >+ >+ public int getWidths() { >+ return widths; >+ } >+ >+ public void setWidths(int widths) { >+ this.widths = widths; >+ } >+ >+ public int getAlignment() { >+ return alignment; >+ } >+ >+ public void setAlignment(int alignment) { >+ this.alignment = alignment; >+ } >+ >+ public void saveState(IMemento memento) { >+ IMemento child = memento.createChild("ColumnState"); //$NON-NLS-1$ >+ child.putString("name", name); //$NON-NLS-1$ >+ child.putInteger("widths", widths); //$NON-NLS-1$ >+ child.putInteger("alignment", alignment); //$NON-NLS-1$ >+ >+ } >+ >+ public static ColumnState createState(IMemento memento) { >+ ColumnState erg; >+ erg = new ColumnState(memento.getString("name"), memento.getInteger("widths")); >+ erg.setAlignment(memento.getInteger("alignment")); >+ return erg; >+ } >+ >+} >\ No newline at end of file >Index: src/org/eclipse/mylyn/internal/tasks/ui/views/AbstractTableViewerConfigurator.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/ui/views/AbstractTableViewerConfigurator.java >diff -N src/org/eclipse/mylyn/internal/tasks/ui/views/AbstractTableViewerConfigurator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/ui/views/AbstractTableViewerConfigurator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,225 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 Frank Becker and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Frank Becker - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.tasks.ui.views; >+ >+import java.io.File; >+import java.io.FileReader; >+import java.io.FileWriter; >+import java.io.IOException; >+import java.util.ArrayList; >+ >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.jface.layout.GridDataFactory; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.ISelectionChangedListener; >+import org.eclipse.jface.viewers.ISelectionProvider; >+import org.eclipse.jface.viewers.TableViewer; >+import org.eclipse.mylyn.commons.core.StatusHandler; >+import org.eclipse.mylyn.internal.tasks.ui.ITasksUiPreferenceConstants; >+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; >+import org.eclipse.mylyn.internal.tasks.ui.util.ColumnState; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.ControlEvent; >+import org.eclipse.swt.events.ControlListener; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Table; >+import org.eclipse.swt.widgets.TableColumn; >+import org.eclipse.ui.IMemento; >+import org.eclipse.ui.WorkbenchException; >+import org.eclipse.ui.XMLMemento; >+import org.eclipse.ui.forms.widgets.FormToolkit; >+ >+public abstract class AbstractTableViewerConfigurator implements ISelectionProvider { >+ protected TableViewer tableViewer; >+ >+ protected Table table; >+ >+ private final File stateFile; >+ >+ protected ArrayList<ColumnState> columnInfos; >+ >+ protected int[] orderArray; >+ >+ public AbstractTableViewerConfigurator(File stateFile) { >+ super(); >+ this.stateFile = stateFile; >+ } >+ >+ abstract protected void setDefaultColumnInfos(); >+ >+ abstract protected void setupTableViewer(); >+ >+ private void readStateFile() { >+ if (stateFile.exists()) { >+ try { >+ FileReader reader = new FileReader(stateFile); >+ try { >+ XMLMemento memento = XMLMemento.createReadRoot(reader); >+ IMemento child = memento.getChild("Columns"); //$NON-NLS-1$ >+ int size = child.getInteger("count"); //$NON-NLS-1$ >+ IMemento[] children = memento.getChildren("ColumnState"); //$NON-NLS-1$ >+ for (int i = 0; i < size; i++) { >+ columnInfos.add(ColumnState.createState(children[i])); >+ } >+ String orderString = child.getString("order"); //$NON-NLS-1$ >+ String[] orderStringArray = orderString.split(","); //$NON-NLS-1$ >+ orderArray = new int[orderStringArray.length]; >+ for (int i = 0; i < orderStringArray.length; i++) { >+ orderArray[i] = Integer.parseInt(orderStringArray[i]); >+ } >+ } catch (WorkbenchException e) { >+ StatusHandler.log(new Status(IStatus.WARNING, TasksUiPlugin.ID_PLUGIN, >+ "The TableViewerState cache could not be read", e)); //$NON-NLS-1$ >+ } finally { >+ reader.close(); >+ } >+ } catch (IOException e) { >+ StatusHandler.log(new Status(IStatus.WARNING, TasksUiPlugin.ID_PLUGIN, >+ "The TableViewerState cache could not be read", e)); //$NON-NLS-1$ >+ } >+ } >+ >+ } >+ >+ protected void writeStateFile() { >+ >+ if (stateFile == null) { >+ return; >+ } >+ >+ XMLMemento memento = XMLMemento.createWriteRoot("TableViewerState"); //$NON-NLS-1$ >+ IMemento child = memento.createChild("Columns"); //$NON-NLS-1$ >+ child.putInteger("count", columnInfos.size()); //$NON-NLS-1$ >+ for (ColumnState col : columnInfos) { >+ col.saveState(memento); >+ } >+ >+ int[] colOrder = table.getColumnOrder(); >+ String orderString = ""; //$NON-NLS-1$ >+ for (int colPos : colOrder) { >+ if (orderString.length() > 0) { >+ orderString += ","; //$NON-NLS-1$ >+ } >+ orderString += colPos; >+ } >+ child.putString("order", orderString); //$NON-NLS-1$ >+ >+ try { >+ FileWriter writer = new FileWriter(stateFile); >+ try { >+ memento.save(writer); >+ } finally { >+ writer.close(); >+ } >+ } catch (IOException e) { >+ StatusHandler.log(new Status(IStatus.WARNING, TasksUiPlugin.ID_PLUGIN, >+ "The TaskEditorAttachment cache could not be written", e)); //$NON-NLS-1$ >+ } >+ } >+ >+ protected void adjustColumInfos() { >+ >+ } >+ >+ public void create(FormToolkit toolkit, Composite parent, int initialColumnCount) { >+ table = createTable(parent, toolkit); >+ columnInfos = new ArrayList<ColumnState>(initialColumnCount); >+ readStateFile(); >+ if (columnInfos.size() == 0) { >+ setDefaultColumnInfos(); >+ } >+ adjustColumInfos(); >+ for (int index = 0; index < columnInfos.size(); index++) { >+ ColumnState colState = columnInfos.get(index); >+ final TableColumn column = new TableColumn(table, colState.getAlignment(), index); >+ column.setText(colState.getName()); >+ column.setWidth(colState.getWidths()); >+ column.setMoveable(true); >+ column.addControlListener(createColumnControlListener(table, column, index)); >+ } >+ >+ tableViewer = new TableViewer(table); >+ table.setColumnOrder(orderArray); >+ setupTableViewer(); >+ } >+ >+ protected ControlListener createColumnControlListener(Table table, final TableColumn column, final int index) { >+ return new ControlListener() { >+ >+ public void controlResized(ControlEvent e) { >+ if (!TasksUiPlugin.getDefault().getPreferenceStore().getBoolean( >+ ITasksUiPreferenceConstants.ATTACHMENT_COLUMN_TO_STD)) { >+ columnInfos.get(index).setWidths(column.getWidth()); >+ writeStateFile(); >+ } >+ } >+ >+ public void controlMoved(ControlEvent e) { >+ writeStateFile(); >+ } >+ }; >+ >+ } >+ >+ protected Table createTable(Composite parent, FormToolkit toolkit) { >+ Table table = toolkit.createTable(parent, SWT.MULTI | SWT.FULL_SELECTION); >+ table.setLinesVisible(true); >+ table.setHeaderVisible(true); >+ table.setLayout(new GridLayout()); >+ GridDataFactory.fillDefaults() >+ .align(SWT.FILL, SWT.FILL) >+ .grab(true, false) >+ .hint(500, SWT.DEFAULT) >+ .applyTo(table); >+ table.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER); >+ >+ return table; >+ } >+ >+ public Table getTable() { >+ return table; >+ } >+ >+ public void resetColumnInfosToDefault() { >+ columnInfos.clear(); >+ setDefaultColumnInfos(); >+ if (!table.isDisposed()) { >+ for (int index = 0; index < columnInfos.size(); index++) { >+ TableColumn col = table.getColumn(index); >+ ColumnState colState = columnInfos.get(index); >+ col.setAlignment(colState.getAlignment()); >+ col.setWidth(colState.getWidths()); >+ col.setText(colState.getName()); >+ } >+ table.setColumnOrder(orderArray); >+ } >+ } >+ >+ public void addSelectionChangedListener(ISelectionChangedListener listener) { >+ tableViewer.addSelectionChangedListener(listener); >+ } >+ >+ public ISelection getSelection() { >+ return tableViewer.getSelection(); >+ } >+ >+ public void removeSelectionChangedListener(ISelectionChangedListener listener) { >+ tableViewer.removeSelectionChangedListener(listener); >+ } >+ >+ public void setSelection(ISelection selection) { >+ tableViewer.setSelection(selection); >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 250257
:
152248
|
152249
|
152640
|
152641
|
158913
|
158914
|
158915
|
158916
|
173981
|
173982
|
174179
|
174180
|
174213
|
174214
|
174251
|
174252
|
175449
|
175450