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 98634 Details for
Bug 229294
[Progress] Layout problems for items in DetailedProgressViewer
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]
patch
progress.patch (text/plain), 37.94 KB, created by
Min Idzelis
on 2008-05-05 09:57:15 EDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Min Idzelis
Created:
2008-05-05 09:57:15 EDT
Size:
37.94 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/internal/progress/DetailedProgressViewer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/DetailedProgressViewer.java,v >retrieving revision 1.31 >diff -u -r1.31 DetailedProgressViewer.java >--- Eclipse UI/org/eclipse/ui/internal/progress/DetailedProgressViewer.java 23 Apr 2008 19:32:55 -0000 1.31 >+++ Eclipse UI/org/eclipse/ui/internal/progress/DetailedProgressViewer.java 5 May 2008 13:53:57 -0000 >@@ -43,8 +43,9 @@ > */ > public class DetailedProgressViewer extends AbstractProgressViewer { > >- //Maximum number of entries to display so that the view does not flood the UI with events >- private static final int MAX_DISPLAYED = 20; >+ // Maximum number of entries to display so that the view does not flood the >+ // UI with events >+ private static final int MAX_DISPLAYED = 100; > > Composite control; > >@@ -52,6 +53,8 @@ > > private Composite noEntryArea; > >+ private Composite currentlyActiveControl; >+ > /** > * Create a new instance of the receiver with a control that is a child of > * parent with style style. >@@ -61,19 +64,17 @@ > */ > public DetailedProgressViewer(Composite parent, int style) { > scrolled = new ScrolledComposite(parent, SWT.V_SCROLL | style); >- int height = JFaceResources.getDefaultFont().getFontData()[0] >- .getHeight(); >+ int height = JFaceResources.getDefaultFont().getFontData()[0].getHeight(); > scrolled.getVerticalBar().setIncrement(height * 2); > scrolled.setExpandHorizontal(true); > scrolled.setExpandVertical(true); > >- control = new Composite(scrolled, SWT.NONE); >+ control = new Composite(scrolled, SWT.BORDER); > GridLayout layout = new GridLayout(); > layout.marginHeight = 0; > layout.marginWidth = 0; > control.setLayout(layout); >- control.setBackground(parent.getDisplay().getSystemColor( >- SWT.COLOR_LIST_BACKGROUND)); >+ control.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); > > control.addFocusListener(new FocusAdapter() { > >@@ -95,15 +96,16 @@ > } > }); > >- control.addControlListener(new ControlListener() { >+ scrolled.addControlListener(new ControlListener() { >+ >+ > /* > * (non-Javadoc) > * > * @see org.eclipse.swt.events.ControlListener#controlMoved(org.eclipse.swt.events.ControlEvent) > */ > public void controlMoved(ControlEvent e) { >- updateVisibleItems(); >- >+ updateSizes(); > } > > /* >@@ -112,14 +114,15 @@ > * @see org.eclipse.swt.events.ControlListener#controlResized(org.eclipse.swt.events.ControlEvent) > */ > public void controlResized(ControlEvent e) { >- updateVisibleItems(); >+ updateSizes(); > } > }); > >+ >+ > PlatformUI.getWorkbench().getHelpSystem().setHelp(control, > IWorkbenchHelpContextIds.RESPONSIVE_UI); > >- scrolled.setContent(control); > hookControl(control); > > noEntryArea = new Composite(scrolled, SWT.NONE); >@@ -136,6 +139,35 @@ > PlatformUI.getWorkbench().getHelpSystem().setHelp(noEntryLabel, > IWorkbenchHelpContextIds.RESPONSIVE_UI); > >+ updateForShowingProgress(); >+ } >+ >+ int doit = 0; >+ >+ void updateSizes() { >+ if (doit == 0) { >+ doit--; >+ scrolled.setRedraw(false); >+ >+ updateVisibleItems(); >+ >+ if (currentlyActiveControl != null) { >+ Point size = currentlyActiveControl.computeSize(scrolled.getClientArea().width, >+ SWT.DEFAULT); >+ size.x -= IDialogConstants.HORIZONTAL_SPACING; >+ size.y -= IDialogConstants.VERTICAL_SPACING; >+// Rectangle r = currentlyActiveControl.getBounds(); >+// r.getClass(); >+ scrolled.setMinHeight(size.y); >+// scrolled.setMinSize(size); >+ >+ scrolled.layout(true); >+ } >+ >+ >+ scrolled.setRedraw(true); >+ doit++; >+ } > } > > /* >@@ -167,6 +199,7 @@ > sorter.sort(this, infos); > } > >+ control.setRedraw(false); > // Update with the new elements to prevent flash > for (int i = 0; i < existingChildren.length; i++) { > ((ProgressInfoItem) existingChildren[i]).dispose(); >@@ -174,23 +207,35 @@ > > int totalSize = Math.min(newItems.size(), MAX_DISPLAYED); > >+ List newInfoItems = new ArrayList(); > for (int i = 0; i < totalSize; i++) { > ProgressInfoItem item = createNewItem(infos[i]); > item.setColor(i); >+ newInfoItems.add(item); > } > >- control.layout(true); > updateForShowingProgress(); >+ >+ updateSizes(); >+ >+ updateVisibleItems(); >+ >+ control.setRedraw(true); > } > > /** > * Update for the progress being displayed. > */ > private void updateForShowingProgress() { >+ Composite oldActive = currentlyActiveControl; > if (control.getChildren().length > 0) { >- scrolled.setContent(control); >- } else { >- scrolled.setContent(noEntryArea); >+ currentlyActiveControl = control; >+ } >+ else { >+ currentlyActiveControl = noEntryArea; >+ } >+ if (oldActive != currentlyActiveControl) { >+ scrolled.setContent(currentlyActiveControl); > } > } > >@@ -201,8 +246,7 @@ > * @return ProgressInfoItem > */ > private ProgressInfoItem createNewItem(JobTreeElement info) { >- final ProgressInfoItem item = new ProgressInfoItem(control, SWT.NONE, >- info); >+ final ProgressInfoItem item = new ProgressInfoItem(control, SWT.NONE, info); > > item.setIndexListener(new ProgressInfoItem.IndexListener() { > /* >@@ -244,8 +288,6 @@ > } > }); > >- // Refresh to populate with the current tasks >- item.refresh(); > return item; > } > >@@ -262,7 +304,8 @@ > ProgressInfoItem previous; > if (i == 0) { > previous = (ProgressInfoItem) children[children.length - 1]; >- } else { >+ } >+ else { > previous = (ProgressInfoItem) children[i - 1]; > } > >@@ -286,7 +329,8 @@ > ProgressInfoItem next; > if (i == children.length - 1) { > next = (ProgressInfoItem) children[0]; >- } else { >+ } >+ else { > next = (ProgressInfoItem) children[i + 1]; > } > item.selectWidgets(false); >@@ -315,8 +359,7 @@ > protected Widget doFindItem(Object element) { > Control[] existingChildren = control.getChildren(); > for (int i = 0; i < existingChildren.length; i++) { >- if (existingChildren[i].isDisposed() >- || existingChildren[i].getData() == null) { >+ if (existingChildren[i].isDisposed() || existingChildren[i].getData() == null) { > continue; > } > if (existingChildren[i].getData().equals(element)) { >@@ -337,7 +380,9 @@ > unmapElement(item); > } > item.dispose(); >- add(new Object[] { element }); >+ add(new Object[] { >+ element >+ }); > } > > /* >@@ -376,6 +421,7 @@ > * @see org.eclipse.jface.viewers.StructuredViewer#internalRefresh(java.lang.Object) > */ > protected void internalRefresh(Object element) { >+ > if (element == null) { > return; > } >@@ -386,17 +432,19 @@ > } > Widget widget = findItem(element); > if (widget == null) { >- add(new Object[] { element }); >+ add(new Object[] { >+ element >+ }); > return; > } >- ((ProgressInfoItem) widget).refresh(); >+ > > // Update the minimum size >- Point size = control.computeSize(SWT.DEFAULT, SWT.DEFAULT); >- size.x += IDialogConstants.HORIZONTAL_SPACING; >- size.y += IDialogConstants.VERTICAL_SPACING; >+ updateSizes(); > >- scrolled.setMinSize(size); >+ ((ProgressInfoItem) widget).refresh(); >+ >+ updateVisibleItems(); > } > > /* >@@ -406,6 +454,7 @@ > */ > public void remove(Object[] elements) { > >+ control.setRedraw(false); > for (int i = 0; i < elements.length; i++) { > JobTreeElement treeElement = (JobTreeElement) elements[i]; > // Make sure we are not keeping this one >@@ -415,7 +464,8 @@ > ((ProgressInfoItem) item).refresh(); > } > >- } else { >+ } >+ else { > Widget item = doFindItem(treeElement); > if (item == null) { > // Is the parent showing? >@@ -435,8 +485,10 @@ > ProgressInfoItem item = (ProgressInfoItem) existingChildren[i]; > item.setColor(i); > } >- control.layout(true); > updateForShowingProgress(); >+ control.layout(true); >+ >+ control.setRedraw(true); > } > > /* >@@ -478,7 +530,8 @@ > item.setButtonFocus(); > return; > } >- } else >+ } >+ else > noEntryArea.setFocus(); > } > >@@ -487,24 +540,30 @@ > */ > private void refreshAll() { > >+ control.setRedraw(false); > Object[] infos = getSortedChildren(getRoot()); > Control[] existingChildren = control.getChildren(); > > for (int i = 0; i < existingChildren.length; i++) { > existingChildren[i].dispose(); >- > } >- >- int maxLength = Math.min(infos.length,MAX_DISPLAYED); >+ >+ int maxLength = Math.min(infos.length, MAX_DISPLAYED); > // Create new ones if required > for (int i = 0; i < maxLength; i++) { > ProgressInfoItem item = createNewItem((JobTreeElement) infos[i]); > item.setColor(i); > } > >- control.layout(true); >- updateForShowingProgress(); > >+// updateForShowingProgress(); >+ scrolled.setContent(currentlyActiveControl); >+ >+ updateSizes(); >+ >+ updateVisibleItems(); >+ >+ control.setRedraw(true); > } > > /** >Index: Eclipse UI/org/eclipse/ui/internal/progress/ProgressInfoItem.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressInfoItem.java,v >retrieving revision 1.51 >diff -u -r1.51 ProgressInfoItem.java >--- Eclipse UI/org/eclipse/ui/internal/progress/ProgressInfoItem.java 24 Apr 2008 18:28:52 -0000 1.51 >+++ Eclipse UI/org/eclipse/ui/internal/progress/ProgressInfoItem.java 5 May 2008 13:53:58 -0000 >@@ -11,11 +11,10 @@ > * IBM Corporation - initial API and implementation > *******************************************************************************/ > import java.net.URL; >-import com.ibm.icu.text.DateFormat; >-import java.util.ArrayList; > import java.util.Date; > import java.util.Iterator; >-import java.util.List; >+import java.util.LinkedList; >+import java.util.ListIterator; > > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.core.runtime.IStatus; >@@ -23,6 +22,8 @@ > import org.eclipse.jface.action.IAction; > import org.eclipse.jface.dialogs.Dialog; > import org.eclipse.jface.dialogs.IDialogConstants; >+import org.eclipse.jface.layout.GridDataFactory; >+import org.eclipse.jface.layout.GridLayoutFactory; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.resource.JFaceResources; > import org.eclipse.jface.resource.LocalResourceManager; >@@ -33,11 +34,13 @@ > import org.eclipse.swt.events.MouseEvent; > import org.eclipse.swt.events.SelectionAdapter; > import org.eclipse.swt.events.SelectionEvent; >-import org.eclipse.swt.graphics.*; >-import org.eclipse.swt.layout.FormAttachment; >-import org.eclipse.swt.layout.FormData; >-import org.eclipse.swt.layout.FormLayout; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.RGB; >+import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.RowLayout; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.Event; >@@ -51,6 +54,8 @@ > import org.eclipse.ui.internal.WorkbenchImages; > import org.eclipse.ui.progress.IProgressConstants; > >+import com.ibm.icu.text.DateFormat; >+ > /** > * ProgressInfoItem is the item used to show jobs. > * >@@ -79,7 +84,7 @@ > > ToolItem actionButton; > >- List taskEntries = new ArrayList(0); >+ LinkedList taskEntries = new LinkedList(); > > private ProgressBar progressBar; > >@@ -89,10 +94,14 @@ > > static final int MIN_ICON_SIZE = 16; > >+ private static final int DIRECTION = SWT.VERTICAL; >+ > private static final String TEXT_KEY = "Text"; //$NON-NLS-1$ > > private static final String ACTION_KEY = "Action";//$NON-NLS-1$ > >+ private static final String JOB = "Job";//$NON-NLS-1$ >+ > interface IndexListener { > /** > * Select the item previous to the receiver. >@@ -122,53 +131,34 @@ > > private ResourceManager resourceManager; > >+ private Composite linkComposite; >+ > static { >- JFaceResources >- .getImageRegistry() >- .put( >- STOP_IMAGE_KEY, >- WorkbenchImages >- .getWorkbenchImageDescriptor("elcl16/progress_stop.gif"));//$NON-NLS-1$ >- >- JFaceResources >- .getImageRegistry() >- .put( >- DISABLED_STOP_IMAGE_KEY, >- WorkbenchImages >- .getWorkbenchImageDescriptor("dlcl16/progress_stop.gif"));//$NON-NLS-1$ >- >- JFaceResources >- .getImageRegistry() >- .put( >- DEFAULT_JOB_KEY, >- WorkbenchImages >- .getWorkbenchImageDescriptor("progress/progress_task.gif")); //$NON-NLS-1$ >- >- JFaceResources >- .getImageRegistry() >- .put( >- CLEAR_FINISHED_JOB_KEY, >- WorkbenchImages >- .getWorkbenchImageDescriptor("elcl16/progress_rem.gif")); //$NON-NLS-1$ >- >- JFaceResources >- .getImageRegistry() >- .put( >- DISABLED_CLEAR_FINISHED_JOB_KEY, >- WorkbenchImages >- .getWorkbenchImageDescriptor("dlcl16/progress_rem.gif")); //$NON-NLS-1$ >+ JFaceResources.getImageRegistry().put(STOP_IMAGE_KEY, >+ WorkbenchImages.getWorkbenchImageDescriptor("elcl16/progress_stop.gif"));//$NON-NLS-1$ >+ >+ JFaceResources.getImageRegistry().put(DISABLED_STOP_IMAGE_KEY, >+ WorkbenchImages.getWorkbenchImageDescriptor("dlcl16/progress_stop.gif"));//$NON-NLS-1$ >+ >+ JFaceResources.getImageRegistry().put(DEFAULT_JOB_KEY, >+ WorkbenchImages.getWorkbenchImageDescriptor("progress/progress_task.gif")); //$NON-NLS-1$ >+ >+ JFaceResources.getImageRegistry().put(CLEAR_FINISHED_JOB_KEY, >+ WorkbenchImages.getWorkbenchImageDescriptor("elcl16/progress_rem.gif")); //$NON-NLS-1$ >+ >+ JFaceResources.getImageRegistry().put(DISABLED_CLEAR_FINISHED_JOB_KEY, >+ WorkbenchImages.getWorkbenchImageDescriptor("dlcl16/progress_rem.gif")); //$NON-NLS-1$ > > // Mac has different Gamma value > int shift = "carbon".equals(SWT.getPlatform()) ? -25 : -10;//$NON-NLS-1$ > >- Color lightColor = PlatformUI.getWorkbench().getDisplay() >- .getSystemColor(SWT.COLOR_LIST_BACKGROUND); >+ Color lightColor = PlatformUI.getWorkbench().getDisplay().getSystemColor( >+ SWT.COLOR_LIST_BACKGROUND); > > // Determine a dark color by shifting the list color >- RGB darkRGB = new RGB(Math.max(0, lightColor.getRed() + shift), Math >- .max(0, lightColor.getGreen() + shift), Math.max(0, lightColor >- .getBlue() >- + shift)); >+ RGB darkRGB = new RGB(Math.max(0, lightColor.getRed() + shift), Math.max(0, lightColor >+ .getGreen() >+ + shift), Math.max(0, lightColor.getBlue() + shift)); > JFaceResources.getColorRegistry().put(DARK_COLOR_KEY, darkRGB); > } > >@@ -180,13 +170,57 @@ > * @param style > * @param progressInfo > */ >- public ProgressInfoItem(Composite parent, int style, >- JobTreeElement progressInfo) { >+ public ProgressInfoItem(Composite parent, int style, JobTreeElement progressInfo) { > super(parent, style); >+ setBackgroundMode(SWT.INHERIT_FORCE); > info = progressInfo; > createChildren(); > setData(info); > setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false)); >+ addListener(SWT.Resize, new Listener() { >+ >+ public void handleEvent(Event event) { >+ >+ refresh(); >+ >+ Point p = new Point(SWT.DEFAULT, SWT.DEFAULT); >+ if (linkComposite != null) { >+ Rectangle area = linkComposite.getClientArea(); >+ p = new Point(area.width, area.height); >+ } >+ updateSizes(p, true); >+ } >+ }); >+ } >+ >+ private int doit = 0; >+ >+ private void updateSizes(Point contraints, boolean performLayout) { >+ >+ if (doit == 0) { >+ setMainText(); >+ >+ if (linkComposite != null) { >+ >+ if (DIRECTION == SWT.HORIZONTAL) { >+ Point preferred = linkComposite.computeSize(contraints.x, SWT.DEFAULT); >+ GridData data = (GridData) linkComposite.getLayoutData(); >+ data.heightHint = preferred.y; >+ } >+ else { >+ Point preferred = linkComposite.computeSize(SWT.DEFAULT, contraints.y); >+ GridData data = (GridData) linkComposite.getLayoutData(); >+ data.widthHint = preferred.x; >+ } >+ >+ } >+ >+ doit--; >+ if (performLayout) { >+ layout(true); >+ } >+ doit++; >+ } > } > > /** >@@ -197,32 +231,29 @@ > */ > protected void createChildren() { > >- FormLayout layout = new FormLayout(); >- setLayout(layout); >+ GridLayoutFactory.fillDefaults().numColumns(3).extendedMargins( >+ IDialogConstants.HORIZONTAL_SPACING / 2, IDialogConstants.HORIZONTAL_SPACING / 2, >+ IDialogConstants.VERTICAL_SPACING / 2, IDialogConstants.VERTICAL_SPACING / 2) >+ .applyTo(this); > > jobImageLabel = new Label(this, SWT.NONE); > jobImageLabel.setImage(getInfoImage()); >- FormData imageData = new FormData(); >- imageData.top = new FormAttachment(IDialogConstants.VERTICAL_SPACING); >- imageData.left = new FormAttachment( >- IDialogConstants.HORIZONTAL_SPACING / 2); >- jobImageLabel.setLayoutData(imageData); >+ GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).span(1, 3).hint(20, 20) >+ .applyTo(jobImageLabel); > > progressLabel = new Label(this, SWT.NONE); >- setMainText(); >+ GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo( >+ progressLabel); >+ >+ actionBar = new ToolBar(this, SWT.NONE); >+ GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).span(1, 3).applyTo(actionBar); > >- actionBar = new ToolBar(this, SWT.FLAT); > actionBar.setCursor(getDisplay().getSystemCursor(SWT.CURSOR_ARROW)); // set >- // cursor >- // to >- // overwrite >- // any >- // busy >+ // cursor to overwrite any busy > > // cursor we might have > actionButton = new ToolItem(actionBar, SWT.NONE); >- actionButton >- .setToolTipText(ProgressMessages.NewProgressView_CancelJobToolTip); >+ actionButton.setToolTipText(ProgressMessages.NewProgressView_CancelJobToolTip); > actionButton.addSelectionListener(new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { > actionButton.setEnabled(false); >@@ -252,14 +283,6 @@ > }); > updateToolBarValues(); > >- FormData progressData = new FormData(); >- progressData.top = new FormAttachment(IDialogConstants.VERTICAL_SPACING); >- progressData.left = new FormAttachment(jobImageLabel, >- IDialogConstants.HORIZONTAL_SPACING / 2); >- progressData.right = new FormAttachment(actionBar, >- IDialogConstants.HORIZONTAL_SPACING); >- progressLabel.setLayoutData(progressData); >- > mouseListener = new MouseAdapter() { > /* > * (non-Javadoc) >@@ -276,8 +299,6 @@ > jobImageLabel.addMouseListener(mouseListener); > progressLabel.addMouseListener(mouseListener); > >- setLayoutsForNoProgress(); >- > refresh(); > } > >@@ -285,31 +306,7 @@ > * Set the main text of the receiver. Truncate to fit the available space. > */ > private void setMainText() { >- progressLabel >- .setText(Dialog.shortenText(getMainTitle(), progressLabel)); >- } >- >- /** >- * Set the layout of the widgets for the no progress case. >- * >- */ >- private void setLayoutsForNoProgress() { >- >- FormData buttonData = new FormData(); >- buttonData.top = new FormAttachment(progressLabel, 0, SWT.TOP); >- buttonData.right = new FormAttachment(100, >- IDialogConstants.HORIZONTAL_SPACING * -1); >- >- actionBar.setLayoutData(buttonData); >- if (taskEntries.size() > 0) { >- FormData linkData = new FormData(); >- linkData.top = new FormAttachment(progressLabel, >- IDialogConstants.VERTICAL_SPACING); >- linkData.left = new FormAttachment(progressLabel, 0, SWT.LEFT); >- linkData.right = new FormAttachment(actionBar, 0, SWT.LEFT); >- ((Link) taskEntries.get(0)).setLayoutData(linkData); >- >- } >+ progressLabel.setText(Dialog.shortenText(getMainTitle(), progressLabel)); > } > > /** >@@ -317,10 +314,11 @@ > * > */ > protected void cancelOrRemove() { >- >- if (FinishedJobs.getInstance().isKept(info) && isCompleted()) { >+ JobInfo[] infos = getJobInfos(); >+ if (FinishedJobs.getInstance().isKept(info) && isCompleted(infos)) { > FinishedJobs.getInstance().remove(info); >- } else { >+ } >+ else { > info.cancel(); > } > >@@ -340,19 +338,20 @@ > JobInfo jobInfo = (JobInfo) info; > > ImageDescriptor descriptor = null; >- Object property = jobInfo.getJob().getProperty( >- IProgressConstants.ICON_PROPERTY); >+ Object property = jobInfo.getJob().getProperty(IProgressConstants.ICON_PROPERTY); > > if (property instanceof ImageDescriptor) { > descriptor = (ImageDescriptor) property; >- } else if (property instanceof URL) { >+ } >+ else if (property instanceof URL) { > descriptor = ImageDescriptor.createFromURL((URL) property); > } > > Image image = null; > if (descriptor == null) { > image = ProgressManager.getInstance().getIconFor(jobInfo.getJob()); >- } else { >+ } >+ else { > image = getResourceManager().createImageWithDefault(descriptor); > } > >@@ -369,8 +368,7 @@ > */ > private ResourceManager getResourceManager() { > if (resourceManager == null) >- resourceManager = new LocalResourceManager(JFaceResources >- .getResources()); >+ resourceManager = new LocalResourceManager(JFaceResources.getResources()); > return resourceManager; > } > >@@ -407,15 +405,13 @@ > > if (jobInfo.isCanceled()) { > if (job.getState() == Job.RUNNING) >- return NLS >- .bind(ProgressMessages.JobInfo_Cancel_Requested, name); >+ return NLS.bind(ProgressMessages.JobInfo_Cancel_Requested, name); > return NLS.bind(ProgressMessages.JobInfo_Cancelled, name); > } > > if (jobInfo.isBlocked()) { > IStatus blockedStatus = jobInfo.getBlockedStatus(); >- return NLS.bind(ProgressMessages.JobInfo_Blocked, name, >- blockedStatus.getMessage()); >+ return NLS.bind(ProgressMessages.JobInfo_Blocked, name, blockedStatus.getMessage()); > } > > switch (job.getState()) { >@@ -446,8 +442,7 @@ > time = getTimeString(); > } > if (time != null) { >- return NLS.bind(ProgressMessages.JobInfo_FinishedAt, job.getName(), >- time); >+ return NLS.bind(ProgressMessages.JobInfo_FinishedAt, job.getName(), time); > } > return NLS.bind(ProgressMessages.JobInfo_Finished, job.getName()); > } >@@ -476,6 +471,8 @@ > if (isDisposed() || !isShowing) > return; > >+ setRedraw(false); >+ > jobImageLabel.setImage(getInfoImage()); > int percentDone = getPercentDone(); > >@@ -493,7 +490,8 @@ > break; > } > } >- } else { >+ } >+ else { > createProgressBar(SWT.NONE); > progressBar.setMinimum(0); > progressBar.setMaximum(100); >@@ -501,19 +499,17 @@ > } > > // Protect against bad counters >- if (percentDone >= 0 && percentDone <= 100 >- && percentDone != progressBar.getSelection()) { >+ if (percentDone >= 0 && percentDone <= 100 && percentDone != progressBar.getSelection()) { > progressBar.setSelection(percentDone); > } > } > >- else if (isCompleted()) { >+ else if (isCompleted(infos)) { > > if (progressBar != null) { > progressBar.dispose(); > progressBar = null; > } >- setLayoutsForNoProgress(); > > } > >@@ -525,30 +521,30 @@ > String subTaskString = null; > Object[] jobChildren = jobInfo.getChildren(); > if (jobChildren.length > 0) { >- subTaskString = ((JobTreeElement) jobChildren[0]) >- .getDisplayString(); >+ subTaskString = ((JobTreeElement) jobChildren[0]).getDisplayString(); > } > > if (subTaskString != null) { > if (taskString == null || taskString.length() == 0) { > taskString = subTaskString; >- } else { >- taskString = NLS.bind( >- ProgressMessages.JobInfo_DoneNoProgressMessage, >+ } >+ else { >+ taskString = NLS.bind(ProgressMessages.JobInfo_DoneNoProgressMessage, > taskString, subTaskString); > } > } > if (taskString != null) { > setLinkText(infos[i].getJob(), taskString, i); > } >- } else {// Check for the finished job state >+ } >+ else {// Check for the finished job state > Job job = jobInfo.getJob(); > IStatus result = job.getResult(); > >- if (result == null || result.getMessage().length() == 0 >- && !info.isJobInfo()) { >- setLinkText(job, getJobNameAndStatus(jobInfo), i); >- } else { >+ if (result == null || result.getMessage().length() == 0 && !info.isJobInfo()) { >+ setLinkText(job, null, i); >+ } >+ else { > setLinkText(job, result.getMessage(), i); > > } >@@ -564,13 +560,14 @@ > > } > if (infos.length > 1) >- taskEntries = taskEntries.subList(0, infos.length - 1); >+ taskEntries.subList(0, infos.length - 1).clear(); > else > taskEntries.clear(); > } > > updateToolBarValues(); >- setMainText(); >+ >+ setRedraw(true); > } > > /** >@@ -578,9 +575,8 @@ > * > * @return boolean <code>true</code> if the state is Job#NONE. > */ >- private boolean isCompleted() { >+ private boolean isCompleted(JobInfo[] infos) { > >- JobInfo[] infos = getJobInfos(); > for (int i = 0; i < infos.length; i++) { > if (infos[i].getJob().getState() != Job.NONE) { > return false; >@@ -597,7 +593,9 @@ > */ > private JobInfo[] getJobInfos() { > if (info.isJobInfo()) { >- return new JobInfo[] { (JobInfo) info }; >+ return new JobInfo[] { >+ (JobInfo) info >+ }; > } > Object[] children = info.getChildren(); > JobInfo[] infos = new JobInfo[children.length]; >@@ -650,24 +648,21 @@ > * > */ > private void updateToolBarValues() { >- if (isCompleted()) { >- actionButton.setImage(JFaceResources >- .getImage(CLEAR_FINISHED_JOB_KEY)); >- actionButton.setDisabledImage(JFaceResources >- .getImage(DISABLED_CLEAR_FINISHED_JOB_KEY)); >- actionButton >- .setToolTipText(ProgressMessages.NewProgressView_ClearJobToolTip); >- } else { >+ JobInfo[] infos = getJobInfos(); >+ if (isCompleted(infos)) { >+ actionButton.setImage(JFaceResources.getImage(CLEAR_FINISHED_JOB_KEY)); >+ actionButton.setDisabledImage(JFaceResources.getImage(DISABLED_CLEAR_FINISHED_JOB_KEY)); >+ actionButton.setToolTipText(ProgressMessages.NewProgressView_ClearJobToolTip); >+ } >+ else { > actionButton.setImage(JFaceResources.getImage(STOP_IMAGE_KEY)); >- actionButton.setDisabledImage(JFaceResources >- .getImage(DISABLED_STOP_IMAGE_KEY)); >+ actionButton.setDisabledImage(JFaceResources.getImage(DISABLED_STOP_IMAGE_KEY)); > > } >- JobInfo[] infos = getJobInfos(); > > for (int i = 0; i < infos.length; i++) { > // Only disable if there is an unresponsive operation >- if (infos[i].isCanceled() && !isCompleted()) { >+ if (infos[i].isCanceled() && !isCompleted(infos)) { > actionButton.setEnabled(false); > return; > } >@@ -682,37 +677,14 @@ > */ > void createProgressBar(int style) { > >- FormData buttonData = new FormData(); >- buttonData.top = new FormAttachment(progressLabel, 0); >- buttonData.right = new FormAttachment(100, >- IDialogConstants.HORIZONTAL_SPACING * -1); >- >- actionBar.setLayoutData(buttonData); >- > progressBar = new ProgressBar(this, SWT.HORIZONTAL | style); >- FormData barData = new FormData(); >- barData.top = new FormAttachment(actionBar, >- IDialogConstants.VERTICAL_SPACING, SWT.TOP); >- barData.left = new FormAttachment(progressLabel, 0, SWT.LEFT); >- barData.right = new FormAttachment(actionBar, >- IDialogConstants.HORIZONTAL_SPACING * -1); >- barData.height = MAX_PROGRESS_HEIGHT; >- barData.width = 0;// default is too large >- progressBar.setLayoutData(barData); >- >- if (taskEntries.size() > 0) { >- // Reattach the link label if there is one >- FormData linkData = new FormData(); >- linkData.top = new FormAttachment(progressBar, >- IDialogConstants.VERTICAL_SPACING); >- linkData.left = new FormAttachment( >- IDialogConstants.HORIZONTAL_SPACING); >- linkData.right = new FormAttachment(progressBar, 0, SWT.RIGHT); >- // Give an initial value so as to constrain the link shortening >- linkData.width = IDialogConstants.INDENT; >- >- ((Link) taskEntries.get(0)).setLayoutData(linkData); >+ progressBar.addMouseListener(mouseListener); >+ if (linkComposite != null) { >+ progressBar.moveAbove(linkComposite); > } >+ GridDataFactory.swtDefaults().hint(SWT.DEFAULT, MAX_PROGRESS_HEIGHT).align(SWT.FILL, >+ SWT.CENTER).applyTo(progressBar); >+ > } > > /** >@@ -722,89 +694,96 @@ > */ > void setLinkText(Job linkJob, String taskString, int index) { > >- Link link; >+ Control subTaskControl = null; > if (index >= taskEntries.size()) {// Is it new? >- link = new Link(this, SWT.NONE); > >- FormData linkData = new FormData(); >- if (index == 0 || taskEntries.size() == 0) { >- Control top = progressBar; >- if (top == null) { >- top = progressLabel; >- } >- linkData.top = new FormAttachment(top, >- IDialogConstants.VERTICAL_SPACING); >- linkData.left = new FormAttachment(top, 0, SWT.LEFT); >- linkData.right = new FormAttachment(progressBar, 0, SWT.RIGHT); >- // Give an initial value so as to constrain the link shortening >- linkData.width = IDialogConstants.INDENT; >- } else { >- Link previous = (Link) taskEntries.get(index - 1); >- linkData.top = new FormAttachment(previous, >- IDialogConstants.VERTICAL_SPACING); >- linkData.left = new FormAttachment(previous, 0, SWT.LEFT); >- linkData.right = new FormAttachment(previous, 0, SWT.RIGHT); >- // Give an initial value so as to constrain the link shortening >- linkData.width = IDialogConstants.INDENT; >- } >- >- link.setLayoutData(linkData); >- >- final Link finalLink = link; >- >- link.addSelectionListener(new SelectionAdapter() { >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) >- */ >- public void widgetSelected(SelectionEvent e) { >- >- IAction action = (IAction) finalLink.getData(ACTION_KEY); >- action.run(); >- >- updateAction(action, finalLink); >- >- Object text = finalLink.getData(TEXT_KEY); >- if (text == null) >- return; >- >- // Refresh the text as enablement might have changed >- updateText((String) text, finalLink); >- } >- }); >- >- link.addListener(SWT.Resize, new Listener() { >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) >- */ >- public void handleEvent(Event event) { >- >- Object text = finalLink.getData(TEXT_KEY); >- if (text == null) >- return; >- >- updateText((String) text, finalLink); >- >- } >- }); >- taskEntries.add(link); >- } else { >- link = (Link) taskEntries.get(index); >- } >- >- link.setToolTipText(taskString); >- link.setData(TEXT_KEY, taskString); >- >- // check for action property >- Object property = linkJob >- .getProperty(IProgressConstants.ACTION_PROPERTY); >- updateAction(property, link); >+ if (needsLinkComposite(taskString, linkJob)) { >+ if (linkComposite == null) { >+ linkComposite = new Composite(this, SWT.NONE); >+ linkComposite.addMouseListener(mouseListener); >+ >+ RowLayout layout = new RowLayout(DIRECTION); >+// layout.justify=true; >+ layout.fill=true; >+ layout.marginBottom = 0; >+ layout.marginLeft = 0; >+ layout.marginRight = 0; >+ layout.marginTop = 0; >+ linkComposite.setLayout(layout); >+ >+ GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false) >+ .applyTo(linkComposite); >+ >+ } >+ if (getAction(linkJob) == null) { >+ subTaskControl = new Label(linkComposite, SWT.NONE); >+ } >+ else { >+ subTaskControl = new Link(linkComposite, SWT.NONE); >+ } >+ addControlListeners(subTaskControl); >+ >+ taskEntries.add(subTaskControl); >+ } >+ } >+ else { >+ subTaskControl = (Control) taskEntries.get(index); >+ } >+ >+ if (subTaskControl != null) { >+ if (taskString != null) { >+ subTaskControl.setToolTipText(taskString); >+ } >+ subTaskControl.setData(TEXT_KEY, taskString); >+ subTaskControl.setData(JOB, linkJob); >+ >+ // check for action property >+ updateAction(linkJob, subTaskControl); >+ >+ updateText(taskString, subTaskControl); >+ } >+ >+ } >+ >+ private void addControlListeners(final Control control) { >+ control.addListener(SWT.Selection, new Listener() { >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) >+ */ >+ public void handleEvent(Event e) { >+ >+ IAction action = (IAction) control.getData(ACTION_KEY); >+ action.run(); >+ >+ updateAction((Job) control.getData(JOB), control); >+ >+ Object text = control.getData(TEXT_KEY); >+ if (text == null) >+ return; >+ >+ // Refresh the text as enablement might have changed >+ updateText((String) text, control); >+ } >+ }); >+ >+ control.addListener(SWT.Resize, new Listener() { >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) >+ */ >+ public void handleEvent(Event event) { >+ >+ Object text = control.getData(TEXT_KEY); >+ if (text == null) >+ return; > >- updateText(taskString, link); >+ updateText((String) text, control); > >+ } >+ }); > } > > /** >@@ -814,14 +793,8 @@ > * {@link Object} or <code>null</code> > * @param link > */ >- private void updateAction(Object action, Link link) { >- >- if (action != null && action instanceof IAction >- && ((IAction) action).isEnabled()) >- link.setData(ACTION_KEY, action); >- else >- link.setData(ACTION_KEY, null); >- >+ private void updateAction(Job linkJob, Control link) { >+ link.setData(ACTION_KEY, getAction(linkJob)); > } > > /** >@@ -830,12 +803,74 @@ > * @param taskString > * @param link > */ >- private void updateText(String taskString, Link link) { >- taskString = Dialog.shortenText(taskString, link); >- >+ private void updateText(String taskString, Control control) { >+ String processedString = Dialog.shortenText(taskString, control.getParent()); > // Put in a hyperlink if there is an action >- link.setText(link.getData(ACTION_KEY) == null ? taskString : NLS.bind( >- "<a>{0}</a>", taskString));//$NON-NLS-1$ >+ IAction action = (IAction) control.getData(ACTION_KEY); >+ if (action != null) { >+ if (processedString == null) { >+ processedString = NLS.bind("<a>{0}</a>", action.getText());//$NON-NLS-1$ >+ } >+ else { >+ processedString = NLS.bind("<a>{0}</a>", processedString);//$NON-NLS-1$ >+ } >+ } >+ if (processedString != null) { >+ if (control instanceof Link) { >+ if (action == null) { >+ Label label = new Label(linkComposite, SWT.NONE); >+ label.moveAbove(control); >+ control.dispose(); >+ label.setText(processedString); >+ addControlListeners(label); >+ for (ListIterator taskItr = taskEntries.listIterator(); taskItr.hasNext();) { >+ Control c = (Control) taskItr.next(); >+ if (c == control) { >+ taskItr.set(label); >+ break; >+ } >+ } >+ } >+ else { >+ ((Link) control).setText(processedString); >+ control.getParent().layout(true); >+ } >+ } >+ else { >+ if (action == null) { >+ ((Label) control).setText(processedString); >+ control.getParent().layout(true); >+ } >+ else { >+ Link link = new Link(linkComposite, SWT.NONE); >+ link.moveAbove(control); >+ control.dispose(); >+ link.setText(processedString); >+ addControlListeners(link); >+ for (ListIterator taskItr = taskEntries.listIterator(); taskItr.hasNext();) { >+ Control c = (Control) taskItr.next(); >+ if (c == control) { >+ taskItr.set(link); >+ break; >+ } >+ } >+ } >+ } >+ } >+ } >+ >+ private IAction getAction(Job linkJob) { >+ Object action = linkJob.getProperty(IProgressConstants.ACTION_PROPERTY); >+ if (action != null && action instanceof IAction && ((IAction) action).isEnabled()) { >+ return (IAction) action; >+ } >+ return null; >+ } >+ >+ private boolean needsLinkComposite(String taskString, Job linkJob) { >+ if (getAction(linkJob) != null) >+ return true; >+ return taskString != null; > } > > /** >@@ -847,22 +882,18 @@ > currentIndex = i; > > if (selected) { >- setAllBackgrounds(getDisplay().getSystemColor( >- SWT.COLOR_LIST_SELECTION)); >- setAllForegrounds(getDisplay().getSystemColor( >- SWT.COLOR_LIST_SELECTION_TEXT)); >+ setAllBackgrounds(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION)); >+ setAllForegrounds(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT)); > return; > } > > if (i % 2 == 0) { >- setAllBackgrounds(JFaceResources.getColorRegistry().get( >- DARK_COLOR_KEY)); >- } else { >- setAllBackgrounds(getDisplay().getSystemColor( >- SWT.COLOR_LIST_BACKGROUND)); >+ setAllBackgrounds(JFaceResources.getColorRegistry().get(DARK_COLOR_KEY)); > } >- setAllForegrounds(getDisplay() >- .getSystemColor(SWT.COLOR_LIST_FOREGROUND)); >+ else { >+ setAllBackgrounds(getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); >+ } >+ setAllForegrounds(getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND)); > } > > /** >@@ -876,7 +907,7 @@ > > Iterator taskEntryIterator = taskEntries.iterator(); > while (taskEntryIterator.hasNext()) { >- ((Link) taskEntryIterator.next()).setForeground(color); >+ ((Control) taskEntryIterator.next()).setForeground(color); > } > > } >@@ -887,16 +918,8 @@ > * @param color > */ > private void setAllBackgrounds(Color color) { >+ // backgrounds are inherited, so only do it once > setBackground(color); >- progressLabel.setBackground(color); >- actionBar.setBackground(color); >- jobImageLabel.setBackground(color); >- >- Iterator taskEntryIterator = taskEntries.iterator(); >- while (taskEntryIterator.hasNext()) { >- ((Link) taskEntryIterator.next()).setBackground(color); >- } >- > } > > /** >@@ -965,13 +988,15 @@ > if (refresh) > refresh(); > } >- >- /* (non-Javadoc) >+ >+ /* >+ * (non-Javadoc) >+ * > * @see org.eclipse.swt.widgets.Widget#dispose() > */ > public void dispose() { > super.dispose(); >- if(resourceManager != null) >+ if (resourceManager != null) > resourceManager.dispose(); > } > }
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 229294
:
97975
| 98634 |
146644