Difference between revisions of "Documentation/DevGuide/GUI/Progress Bar"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (FINAL VERSION FOR L10N)
 
Line 8: Line 8:
 
{{Documentation/DevGuideLanguages|Documentation/DevGuide/GUI/{{SUBPAGENAME}}}}  
 
{{Documentation/DevGuideLanguages|Documentation/DevGuide/GUI/{{SUBPAGENAME}}}}  
 
  {{DISPLAYTITLE:Progress Bar}}
 
  {{DISPLAYTITLE:Progress Bar}}
The progress bar control <idl>com.sun.star.awt.UnoControlProgressBar</idl> displays a growing or shrinking bar to give the user feedback during a persisting task. The minimum and the maximum progress value of the control is set by the <code>ProgressValueMin</code> and the <code>ProgressValueMax</code> properties of the control model that supports the service <idl>com.sun.star.awt.UnoControlProgressBarModel</idl> . The progress value is controlled by the <code>ProgressValue</code> property. The fill color can be changed by setting the property <code>FillColor</code>. The control implements the interface <idl>com.sun.star.awt.XProgressBar</idl> which allows you to control the progress bar. The progress bar interface <idl>com.sun.star.awt.XReschedule</idl> helps to update and repaint the progress bar while a concurrent task is running, but this interface interrupts the main thread of the office. Issue http://www.openoffice.org/issues/show_bug.cgi?id=i71425 is assigned to find an appropriate solution for this problem.
+
The progress bar control <idl>com.sun.star.awt.UnoControlProgressBar</idl> displays a growing or shrinking bar to give the user feedback during a persisting task. The minimum and the maximum progress value of the control is set by the <code>ProgressValueMin</code> and the <code>ProgressValueMax</code> properties of the control model that supports the service <idl>com.sun.star.awt.UnoControlProgressBarModel</idl> . The progress value is controlled by the <code>ProgressValue</code> property. The fill color can be changed by setting the property <code>FillColor</code>. The control implements the interface <idl>com.sun.star.awt.XProgressBar</idl> which allows you to control the progress bar. The progress bar interface <idl>com.sun.star.awt.XReschedule</idl> helps to update and repaint the progress bar while a concurrent task is running, but this interface interrupts the main thread of the office. Issue https://www.openoffice.org/issues/show_bug.cgi?id=i71425 is assigned to find an appropriate solution for this problem.
<source lang="java">
+
<syntaxhighlight lang="java">
 
   public XPropertySet insertProgressBar(int _nPosX, int _nPosY, int _nWidth, int _nProgressMax){
 
   public XPropertySet insertProgressBar(int _nPosX, int _nPosY, int _nWidth, int _nProgressMax){
 
   XPropertySet xPBModelPSet = null;
 
   XPropertySet xPBModelPSet = null;
Line 47: Line 47:
 
       return xPBModelPSet;
 
       return xPBModelPSet;
 
   }
 
   }
</source>
+
</syntaxhighlight>
 
{{PDL1}}
 
{{PDL1}}
  
 
[[Category:Documentation/Developer's Guide/Graphical User Interfaces]]
 
[[Category:Documentation/Developer's Guide/Graphical User Interfaces]]

Latest revision as of 12:45, 22 December 2020



The progress bar control com.sun.star.awt.UnoControlProgressBar displays a growing or shrinking bar to give the user feedback during a persisting task. The minimum and the maximum progress value of the control is set by the ProgressValueMin and the ProgressValueMax properties of the control model that supports the service com.sun.star.awt.UnoControlProgressBarModel . The progress value is controlled by the ProgressValue property. The fill color can be changed by setting the property FillColor. The control implements the interface com.sun.star.awt.XProgressBar which allows you to control the progress bar. The progress bar interface com.sun.star.awt.XReschedule helps to update and repaint the progress bar while a concurrent task is running, but this interface interrupts the main thread of the office. Issue https://www.openoffice.org/issues/show_bug.cgi?id=i71425 is assigned to find an appropriate solution for this problem.

  public XPropertySet insertProgressBar(int _nPosX, int _nPosY, int _nWidth, int _nProgressMax){
  XPropertySet xPBModelPSet = null;
  try{
      // create a unique name by means of an own implementation...
      String sName = createUniqueName(m_xDlgModelNameContainer, "ProgressBar");
 
      // create a controlmodel at the multiservicefactory of the dialog model... 
      Object oPBModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlProgressBarModel");
 
      XMultiPropertySet xPBModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oPBModel);
      // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
      xPBModelMPSet.setPropertyValues(
      new String[] {"Height", "Name", "PositionX", "PositionY", "Width"},
      new Object[] { new Integer(8), sName, new Integer(_nPosX), new Integer(_nPosY), new Integer(_nWidth)});
 
      // The controlmodel is not really available until inserted to the Dialog container
      m_xDlgModelNameContainer.insertByName(sName, oPBModel);
      xPBModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oPBModel);
 
      // The following properties may also be set with XMultiPropertySet but we
      // use the XPropertySet interface merely for reasons of demonstration
      xPBModelPSet.setPropertyValue("ProgressValueMin", new Integer(0));
      xPBModelPSet.setPropertyValue("ProgressValueMax", new Integer(_nProgressMax));
  }catch (com.sun.star.uno.Exception ex){
      /* perform individual exception handling here.
       * Possible exception types are:
       * com.sun.star.lang.IllegalArgumentException,
       * com.sun.star.lang.WrappedTargetException,
       * com.sun.star.container.ElementExistException,
       * com.sun.star.beans.PropertyVetoException,
       * com.sun.star.beans.UnknownPropertyException,
       * com.sun.star.uno.Exception
       */
      ex.printStackTrace(System.out);
  }
      return xPBModelPSet;
  }
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages