openoffice-api mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Engin Oz <o.engi...@gmail.com>
Subject Re: Can not add control to XSidebarPanel
Date Mon, 16 Mar 2015 17:54:28 GMT
In log file, i have these,

opening log file 1426528385.878000 seconds past January 1st 1970
corresponding to 0 ms after timer start
Process id is 4252
000001 3484 | : PERFORMANCE - enter Main()
000666 3484 | : PERFORMANCE - enter Application::Execute()
000667 3484 { PERFORMANCE - DesktopOpenClients_Impl()
000678 3484 } PERFORMANCE - DesktopOpenClients_Impl()
002160 3484 { XCUBasedAcceleratorConfiguration::reload()
002164 3484 } XCUBasedAcceleratorConfiguration::reload()
002164 3484 { XCUBasedAcceleratorConfiguration::reload()
002165 3484 } XCUBasedAcceleratorConfiguration::reload()
002188 3484 { XCUBasedAcceleratorConfiguration::reload()
002189 3484 } XCUBasedAcceleratorConfiguration::reload()
002275 3484 { XCUBasedAcceleratorConfiguration::reload()
002276 3484 } XCUBasedAcceleratorConfiguration::reload()
002347 3484 { XCUBasedAcceleratorConfiguration::reload()
002348 3484 } XCUBasedAcceleratorConfiguration::reload()
closing log file at 015266

On 16.3.2015 18:28, Alexandro Colorado wrote:
> Do you have any error log?
> https://wiki.openoffice.org/wiki/Uno/Spec/Log_Environment
>
> On Mon, Mar 16, 2015 at 9:41 AM, Engin GMAIL <o.enginoz@gmail.com> wrote:
>
>> Hi;
>>
>> I'm trying to write sidebar extension for openoffice. I've read sidebar
>> for developers from wiki. (https://wiki.openoffice.org/
>> wiki/Sidebar_for_Developers)
>> And i modify like below, but i can not add button control. How can i add
>> control to XSidebarPanel ?
>>
>> package org.apache.openoffice.sidebar;
>>
>> import java.util.Vector;
>>
>> import com.sun.star.accessibility.XAccessible;
>> import com.sun.star.awt.Rectangle;
>> import com.sun.star.awt.Size;
>> import com.sun.star.awt.WindowAttribute;
>> import com.sun.star.awt.WindowClass;
>> import com.sun.star.awt.WindowDescriptor;
>> import com.sun.star.awt.WindowEvent;
>> import com.sun.star.awt.XToolkit;
>> import com.sun.star.awt.XWindow;
>> import com.sun.star.awt.XWindowListener;
>> import com.sun.star.awt.XWindowPeer;
>> import com.sun.star.beans.XPropertySet;
>> import com.sun.star.container.XNameContainer;
>> import com.sun.star.lang.DisposedException;
>> import com.sun.star.lang.EventObject;
>> import com.sun.star.lang.XComponent;
>> import com.sun.star.lang.XEventListener;
>> import com.sun.star.lang.XMultiComponentFactory;
>> import com.sun.star.lang.XMultiServiceFactory;
>> import com.sun.star.ui.LayoutSize;
>> import com.sun.star.ui.XSidebarPanel;
>> import com.sun.star.ui.XToolPanel;
>> import com.sun.star.uno.Exception;
>> import com.sun.star.uno.UnoRuntime;
>> import com.sun.star.uno.XComponentContext;
>>
>> public abstract class PanelBase implements XToolPanel, XWindowListener,
>>      XSidebarPanel, XComponent {
>>      /**
>>       * This is the one method that a derived class has to implement: how to
>>       * react to size changes of the content window.
>>       */
>>      abstract protected void Layout(final Size aWindowSize);
>>
>>      protected PanelBase() {
>>          maDisposeListeners = new Vector<XEventListener>();
>>      }
>>
>>      protected void Initialize(final XWindow xParentWindow,
>>          final XComponentContext xContext) {
>>          Log.Instance().println("creating panel");
>>
>>          // Create the content window of the panel.
>>          try {
>>              XWindowPeer xParentPeer =
>>                  (XWindowPeer) UnoRuntime.queryInterface(XWindowPeer.class,
>>                      xParentWindow);
>>              if (xParentPeer != null) {
>>                  xParentWindow.addWindowListener(this);
>>
>>                  if (xContext == null)
>>                      throw new RuntimeException("got null XContext");
>>                  XMultiComponentFactory xFactory =
>> xContext.getServiceManager();
>>                  if (xFactory == null)
>>                      throw new RuntimeException(
>>                          "can not acquire factor from XContext");
>>
>>                  XToolkit xToolkit =
>>                      (XToolkit) UnoRuntime.queryInterface(XToolkit.class,
>>                          xFactory.createInstanceWithContext(
>>                              "com.sun.star.awt.Toolkit", xContext));
>>                  WindowDescriptor aWindowDescriptor =
>>                      new WindowDescriptor(WindowClass.CONTAINER, "",
>>                          xParentPeer, (short) -1, // parent index not
>> available
>>                          new Rectangle(0, 0, 10, 10),
>> WindowAttribute.SIZEABLE
>>                              | WindowAttribute.MOVEABLE
>>                              | WindowAttribute.NODECORATION);
>>                  mxWindow =
>>                      (XWindow) UnoRuntime.queryInterface(XWindow.class,
>>                          xToolkit.createWindow(aWindowDescriptor));
>>                  if (mxWindow == null)
>>                      throw new RuntimeException(
>>                          "can not create XWindow for parent " +
>> xParentPeer);
>>
>>                  // Make the background transparent. The slide show paints
>> its
>>                  // own background.
>>                  final XWindowPeer xPeer =
>>                      (XWindowPeer) UnoRuntime.queryInterface(
>> XWindowPeer.class,
>>                          mxWindow);
>>                  if (xPeer != null) {
>>                      // Make the window background transparent to avoid some
>>                      // flickering,
>>                      // when first the window background and then the canvas
>>                      // content is painted.
>>                      // xPeer.setBackground(0xffffff);
>>                      xPeer.setBackground(0xfff000);
>>                  }
>>
>>                  XMultiServiceFactory xMultiServiceFactory =
>>                      (XMultiServiceFactory) xContext.getServiceManager();
>>
>>                  try {
>>                      String _buttonName = "mahooo";
>>                      // create the button model and set the properties
>>                      Object buttonModel =
>>                          xMultiServiceFactory
>> .createInstance("com.sun.star.awt.UnoControlButtonModel");
>>                      XPropertySet xPSetButton =
>>                          (XPropertySet) UnoRuntime.queryInterface(
>>                              XPropertySet.class, buttonModel);
>>                      xPSetButton.setPropertyValue("PositionX", new
>> Integer(20));
>>                      xPSetButton.setPropertyValue("PositionY", new
>> Integer(70));
>>                      xPSetButton.setPropertyValue("Width", new
>> Integer(50));
>>                      xPSetButton.setPropertyValue("Height", new
>> Integer(14));
>>                      xPSetButton.setPropertyValue("Name", _buttonName);
>>                      xPSetButton.setPropertyValue("TabIndex", new Short(
>>                          (short) 0));
>>                      xPSetButton.setPropertyValue("Label",
>>                          new String("Click Me"));
>>
>>                      XNameContainer xNameCont =
>>                          (XNameContainer) UnoRuntime.queryInterface(
>>                              XNameContainer.class, xPeer);
>>                      xNameCont.insertByName(_buttonName, buttonModel);
>>                  } catch (Exception e) {
>>                      // TODO Auto-generated catch block
>>                      e.printStackTrace();
>>                  }
>>
>>                  mxWindow.setVisible(true);
>>              }
>>          } catch (Exception aException) {
>>              Log.Instance().PrintStackTrace(aException);
>>              throw new RuntimeException("can not create window for Panel: "
>>                  + aException.getMessage());
>>          }
>>      }
>>
>>      // ----- Implementation of UNO interface XWindowListener -----
>>
>>      @Override
>>      public void windowHidden(final EventObject aEvent) {
>>          CallLayout(0, 0);
>>      }
>>
>>      @Override
>>      public void windowMoved(final WindowEvent aEvent) {
>>          CallLayout(aEvent.Width, aEvent.Height);
>>      }
>>
>>      @Override
>>      public void windowResized(final WindowEvent aEvent) {
>>          CallLayout(aEvent.Width, aEvent.Height);
>>      }
>>
>>      @Override
>>      public void windowShown(final EventObject aEvent) {
>>          CallLayout(mxWindow.getPosSize().Width,
>> mxWindow.getPosSize().Height);
>>      }
>>
>>      @Override
>>      public void disposing(final EventObject aEvent) {
>>          mxWindow = null;
>>      }
>>
>>      // ----- Implementation of UNO interface XToolPanel -----
>>
>>      @Override
>>      public XAccessible createAccessible(XAccessible arg0) {
>>          return (XAccessible) UnoRuntime.queryInterface(XAccessible.class,
>>              getWindow());
>>      }
>>
>>      @Override
>>      public XWindow getWindow() {
>>          if (mxWindow == null)
>>              throw new DisposedException("Panel is already disposed", this);
>>
>>          return mxWindow;
>>      }
>>
>>      // ----- Implementation of UNO interface XSidebarPanel -----
>>
>>      @Override
>>      public LayoutSize getHeightForWidth(final int nWidth) {
>>          return new LayoutSize(0, 0, 0);
>>      }
>>
>>      // ----- Implementation of UNO interface XComponent -----
>>
>>      @Override
>>      public void dispose() {
>>          EventObject aEvent = new EventObject(this);
>>          for (final XEventListener xListener : maDisposeListeners)
>>              xListener.disposing(aEvent);
>>      }
>>
>>      @Override
>>      public void addEventListener(final XEventListener xListener) {
>>          maDisposeListeners.add(xListener);
>>      }
>>
>>      @Override
>>      public void removeEventListener(final XEventListener xListener) {
>>          maDisposeListeners.remove(xListener);
>>      }
>>
>>      // ----- private methods -----
>>
>>      private void CallLayout(final int nWidth, final int nHeight) {
>>          Layout(new Size(nWidth, nHeight));
>>      }
>>
>>      protected XWindow mxWindow;
>>      private final Vector<XEventListener> maDisposeListeners;
>> }
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: api-unsubscribe@openoffice.apache.org
>> For additional commands, e-mail: api-help@openoffice.apache.org
>>
>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscribe@openoffice.apache.org
For additional commands, e-mail: api-help@openoffice.apache.org


Mime
View raw message