OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Enable / Disable option in a addon toolbar extension -solved

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets
View previous topic :: View next topic  
Author Message
darkman97i
Newbie
Newbie


Joined: 11 Feb 2010
Posts: 4

PostPosted: Mon Sep 13, 2010 1:45 am    Post subject: Enable / Disable option in a addon toolbar extension -solved Reply with quote

I've been two days trying to enable / disable a button in a toolbar without no success, probably it's easy but I've not found anyway the tree magic lines for doing it:

My Addons.xcu file is as:

Code:

<?xml version='1.0' encoding='UTF-8'?>

<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="Addons" oor:package="org.openoffice.Office">
  <node oor:name="AddonUI">

    <node oor:name="OfficeToolBar">
      <node oor:name="com.openkm.openoffice.openkmaddon" oor:op="replace">
      <node oor:name="m1" oor:op="replace">
        <prop oor:name="URL" oor:type="xs:string">
          <value>com.openkm.openoffice.openkmaddon:config</value>
        </prop>
        <prop oor:name="ImageIdentifier" oor:type="xs:string">
          <value/>
        </prop>
        <prop oor:name="Target" oor:type="xs:string">
          <value>_self</value>
        </prop>
        <prop oor:name="Context" oor:type="xs:string">
          <value>com.sun.star.presentation.PresentationDocument,com.sun.star.sheet.SpreadsheetDocument,com.sun.star.text.TextDocument</value>
        </prop>
        <prop oor:name="Title" oor:type="xs:string">
          <value/>
          <value xml:lang="en">Config</value>
          <value xml:lang="es">ConfiguraciĆ³n</value>
        </prop>
      </node>


In my java code finally I can hide all toolbar with
Code:

XPropertySet props = ( XPropertySet ) UnoRuntime.queryInterface( XPropertySet.class, m_xFrame );
                Object obj;
                try {
                    obj = props.getPropertyValue("LayoutManager");
                    XLayoutManager result = ( XLayoutManager ) UnoRuntime.queryInterface( XLayoutManager.class, obj );


                    XUIElement element = result.getElement("private:resource/toolbar/addon_com.openkm.openoffice.openkmaddon");
                    result.hideElement("private:resource/toolbar/addon_com.openkm.openoffice.openkmaddon");


But the question is not how to accessing all toolbar, the question is how to accessing some button on the tool bar I've tryed with that possible String among others without success ( that seems the more logical ):
private:resource/toolbar/addon_com.openkm.openoffice.openkmaddon/config
private:resource/toolbar/addon_com.openkm.openoffice.openkmaddon/m1
private:resource/toolbar/addon_com.openkm.openoffice.openkmaddon/com.openkm.openoffice.openkmaddon:config

Any help it'll be apreciate


Last edited by darkman97i on Tue Oct 05, 2010 2:57 am; edited 1 time in total
Back to top
View user's profile Send private message
darkman97i
Newbie
Newbie


Joined: 11 Feb 2010
Posts: 4

PostPosted: Tue Sep 14, 2010 7:13 am    Post subject: Reply with quote

That code has been running to me

Code:
public void addStatusListener( com.sun.star.frame.XStatusListener xControl,
                                    com.sun.star.util.URL aURL )
    {
        try {
            boolean isOpenKMDoc = false;

            if (!getCurrentDocumentPath().equals("")) {
                System.out.println(getCurrentDocumentPath());
                if (DocumentFile.isOpenKMDocument(getCurrentDocumentPath())) {
                    System.out.println("document localitzat");
                    isOpenKMDoc = true;
                }
            }

            if ( aURL.Protocol.compareTo("com.openkm.openoffice.openkmaddon:") == 0 )
            {
                if ( aURL.Path.compareTo("add") == 0 ) {
                    com.sun.star.util.URL buttonAdd = new com.sun.star.util.URL();
                    buttonAdd.Path = "add";
                    buttonAdd.Protocol  = "com.openkm.openoffice.openkmaddon:";
                    buttonAdd.Complete = "com.openkm.openoffice.openkmaddon:add";
                    FeatureStateEvent fsEventAdd = new FeatureStateEvent();
                    fsEventAdd.FeatureURL = buttonAdd;
                    fsEventAdd.Source = this;
                    fsEventAdd.IsEnabled = !isOpenKMDoc;
                    fsEventAdd.Requery = false;
                    xControl.statusChanged(fsEventAdd);
                }
                if ( aURL.Path.compareTo("edit") == 0 ) {
                    com.sun.star.util.URL buttonEdit = new com.sun.star.util.URL();
                    buttonEdit.Path = "edit";
                    buttonEdit.Protocol  = "com.openkm.openoffice.openkmaddon:";
                    buttonEdit.Complete = "com.openkm.openoffice.openkmaddon:edit";
                    FeatureStateEvent fsEventEdit = new FeatureStateEvent();
                    fsEventEdit.FeatureURL = buttonEdit;
                    fsEventEdit.Source = this;
                    fsEventEdit.IsEnabled = !isOpenKMDoc;
                    fsEventEdit.Requery = false;
                    xControl.statusChanged(fsEventEdit);
                }

                if ( aURL.Path.compareTo("checkin") == 0 ) {
                    com.sun.star.util.URL buttonCheckin = new com.sun.star.util.URL();
                    buttonCheckin.Path = "checkin";
                    buttonCheckin.Protocol  = "com.openkm.openoffice.openkmaddon:";
                    buttonCheckin.Complete = "com.openkm.openoffice.openkmaddon:checkin";
                    FeatureStateEvent fsEventCheckin = new FeatureStateEvent();
                    fsEventCheckin.FeatureURL = buttonCheckin;
                    fsEventCheckin.Source = this;
                    fsEventCheckin.IsEnabled = isOpenKMDoc;
                    fsEventCheckin.Requery = false;
                    xControl.statusChanged(fsEventCheckin);
                }

                if ( aURL.Path.compareTo("cancelcheckin") == 0 ) {
                    com.sun.star.util.URL  buttonCancelCheckin = new com.sun.star.util.URL();
                    buttonCancelCheckin.Path = "cancelcheckin";
                    buttonCancelCheckin.Protocol  = "com.openkm.openoffice.openkmaddon:";
                    buttonCancelCheckin.Complete = "com.openkm.openoffice.openkmaddon:cancelcheckin";
                    FeatureStateEvent fsEventCancelCheckin = new FeatureStateEvent();
                    fsEventCancelCheckin.FeatureURL = buttonCancelCheckin;
                    fsEventCancelCheckin.Source = this;
                    fsEventCancelCheckin.IsEnabled = isOpenKMDoc;
                    fsEventCancelCheckin.Requery = false;
                    xControl.statusChanged(fsEventCancelCheckin);
                }
            }

        } catch (OKMException ex) {
        }
    }
Back to top
View user's profile Send private message
ottoshmidt1
Power User
Power User


Joined: 15 May 2009
Posts: 69
Location: Tbilisi, Georgia

PostPosted: Tue Oct 05, 2010 2:41 am    Post subject: Reply with quote

is it a snippet or question?
_________________
[Solved] mark in title significantly facilitates the work of those who try to help. So please, be gentle and don't forget to insert it. Wink

IRC: /join #openoffice.org on irc.freenode.net
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
darkman97i
Newbie
Newbie


Joined: 11 Feb 2010
Posts: 4

PostPosted: Tue Oct 05, 2010 2:57 am    Post subject: Reply with quote

It's was question, and I founded a possible solution to the question. I posted it because I had not found in other forum some information about it.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group