Changeset 87 in main for trunk/plugins
- Timestamp:
- 07/15/10 09:24:45 (12 years ago)
- Location:
- trunk/plugins/openoffice
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/openoffice/Addons.xcu
r86 r87 48 48 </prop> 49 49 </node> 50 51 <node oor:name="m4" oor:op="replace"> 52 <prop oor:name="Title" oor:type="xs:string"> 53 <value>Forget current file</value> 54 </prop> 55 <prop oor:name="URL" oor:type="xs:string"> 56 <value>service:org.example.OpenPLMForget</value> 57 </prop> 58 <prop oor:name="Target" oor:type="xs:string"> 59 <value>_self</value> 60 </prop> 61 </node> 62 63 <node oor:name="m5" oor:op="replace"> 64 <prop oor:name="Title" oor:type="xs:string"> 65 <value>Check-in</value> 66 </prop> 67 <prop oor:name="URL" oor:type="xs:string"> 68 <value>service:org.example.OpenPLMCheckIn</value> 69 </prop> 70 <prop oor:name="Target" oor:type="xs:string"> 71 <value>_self</value> 72 </prop> 73 </node> 50 74 51 75 </node> -
trunk/plugins/openoffice/openplm.py
r86 r87 197 197 198 198 def forget(self, gdoc=None, delete=True): 199 gdoc = gdoc or self._window.get_active_document() 200 doc = gdoc.get_data("openplm_doc") 201 doc_file_id = gdoc.get_data("openplm_file_id") 202 path = gdoc.get_data("openplm_path") 203 if doc and doc_file_id and path: 204 label = gdoc.get_data("openplm_label") 205 label.destroy() 199 gdoc = gdoc or self.desktop.getCurrentComponent() 200 if gdoc and gdoc.URL in self.documents: 201 doc = self.documents[gdoc.URL]["openplm_doc"] 202 doc_file_id = self.documents[gdoc.URL]["openplm_file_id"] 203 path = self.documents[gdoc.URL]["openplm_path"] 204 del self.documents[gdoc.URL] 206 205 data = self.get_conf_data() 207 206 del data["documents"][str(doc["id"])]["files"][str(doc_file_id)] … … 239 238 240 239 def check_in(self, gdoc, unlock, save=True): 241 doc = gdoc.get_data("openplm_doc")242 doc_file_id = gdoc.get_data("openplm_file_id")243 path = gdoc.get_data("openplm_path")244 if doc and doc_file_id and path:240 if gdoc and gdoc.URL in self.documents: 241 doc = self.documents[gdoc.URL]["openplm_doc"] 242 doc_file_id = self.documents[gdoc.URL]["openplm_file_id"] 243 path = self.documents[gdoc.URL]["openplm_path"] 245 244 def func(): 246 245 # headers contains the necessary Content-Type and Content-Length> … … 254 253 self.get_data("api/object/%s/lock/%s/" % (doc["id"], doc_file_id)) 255 254 if save: 256 save_document(self._window, gdoc, func) 255 gdoc.store() 256 func() 257 257 else: 258 258 func() … … 262 262 pass 263 263 264 def check_in_cb(self):265 gdoc = self._window.get_active_document()266 doc = gdoc.get_data("openplm_doc")267 doc_file_id = gdoc.get_data("openplm_file_id")268 if not doc or not self.check_is_locked(doc["id"], doc_file_id):269 return270 name = os.path.basename(gdoc.get_data("openplm_path"))271 diag = CheckInDialog(self._window, self, doc, name)272 resp = diag.run()273 if resp == gtk.RESPONSE_ACCEPT:274 self.check_in(gdoc, diag.get_unlock())275 diag.destroy()276 277 264 def revise(self, gdoc, revision, unlock): 278 265 doc = gdoc.get_data("openplm_doc") … … 350 337 351 338 class Dialog(unohelper.Base, XActionListener): 339 340 TITLE = "Search" 341 ACTION_NAME = "..." 342 343 WIDTH = 200 344 HEIGHT = 300 345 PAD = 5 346 ROW_HEIGHT = 15 347 ROW_PAD = 2 348 352 349 def __init__(self, ctx): 353 350 self.ctx = ctx … … 433 430 self.dialog.Height = 105 434 431 self.dialog.Title = 'Login' 435 label = self.addWidget('Username', 'FixedText', 5, 10, 100, 14,432 label = self.addWidget('Username', 'FixedText', 5, 10, 60, 14, 436 433 Label = 'Username:') 437 434 self.username = self.addWidget('UsernameEntry', 'Edit', 90, 10, 100, 14) 438 label = self.addWidget('password', 'FixedText', 5, 30, 100, 14,435 label = self.addWidget('password', 'FixedText', 5, 30, 60, 14, 439 436 Label = 'Password:') 440 437 self.password = self.addWidget('PasswordEntry', 'Edit', 90, 30, 100, 14, … … 672 669 self.container.endExecute() 673 670 674 671 class CheckInDialog(Dialog): 672 673 TITLE = "Check-in..." 674 ACTION_NAME = "Check-in" 675 WIDTH = 200 676 HEIGHT = 100 677 678 def __init__(self, ctx, doc, name): 679 Dialog.__init__(self, ctx) 680 self.doc = doc 681 self.name = name 682 683 def run(self): 684 smgr = self.ctx.ServiceManager 685 self.dialog = smgr.createInstanceWithContext( 686 'com.sun.star.awt.UnoControlDialogModel', self.ctx) 687 self.dialog.Width = self.WIDTH 688 self.dialog.Height = self.HEIGHT 689 self.dialog.Title = self.TITLE 690 691 text = "%s|%s|%s" % (self.doc["reference"], self.doc["revision"], 692 self.doc["type"]) 693 694 label = self.addWidget('Username', 'FixedText', 5, 10, 60, 14, 695 Label = text) 696 self.unlock_button = self.addWidget('unlock_button', 'CheckBox', 697 5, 30, 100, 14, Label='Unlock ?') 698 699 button = self.addWidget('action', 'Button', 55, 85, 50, 14, 700 Label=self.ACTION_NAME) 701 self.container = smgr.createInstanceWithContext( 702 'com.sun.star.awt.UnoControlDialog', self.ctx) 703 self.container.setModel(self.dialog) 704 self.container.getControl('action').addActionListener(self) 705 toolkit = smgr.createInstanceWithContext( 706 'com.sun.star.awt.ExtToolkit', self.ctx) 707 self.container.setVisible(False) 708 self.container.createPeer(toolkit, None) 709 self.container.execute() 710 711 def actionPerformed(self, actionEvent): 712 try: 713 try: 714 desktop = self.ctx.ServiceManager.createInstanceWithContext( 715 'com.sun.star.frame.Desktop', self.ctx) 716 PLUGIN.check_in(desktop.getCurrentComponent(), 717 self.get_value(self.unlock_button, None)) 718 self.container.endExecute() 719 except ValueError, e: 720 print e 721 except: 722 traceback.print_exc() 675 723 class OpenPLMLogin(unohelper.Base, XJobExecutor): 676 724 def __init__(self, ctx): … … 716 764 traceback.print_exc() 717 765 766 class OpenPLMForget(unohelper.Base, XJobExecutor): 767 def __init__(self, ctx): 768 self.ctx = ctx 769 770 def trigger(self, args): 771 try: 772 desktop = self.ctx.ServiceManager.createInstanceWithContext( 773 'com.sun.star.frame.Desktop', self.ctx) 774 PLUGIN.set_desktop(desktop) 775 PLUGIN.forget() 776 except: 777 traceback.print_exc() 778 779 class OpenPLMCheckIn(unohelper.Base, XJobExecutor): 780 def __init__(self, ctx): 781 self.ctx = ctx 782 783 def trigger(self, args): 784 try: 785 desktop = self.ctx.ServiceManager.createInstanceWithContext( 786 'com.sun.star.frame.Desktop', self.ctx) 787 PLUGIN.set_desktop(desktop) 788 gdoc = desktop.getCurrentComponent() 789 if gdoc and gdoc.URL in PLUGIN.documents: 790 doc = PLUGIN.documents[gdoc.URL]["openplm_doc"] 791 doc_file_id = PLUGIN.documents[gdoc.URL]["openplm_file_id"] 792 path = PLUGIN.documents[gdoc.URL]["openplm_path"] 793 if not doc or not PLUGIN.check_is_locked(doc["id"], doc_file_id): 794 return 795 name = os.path.basename(path) 796 dialog = CheckInDialog(self.ctx, doc, name) 797 dialog.run() 798 except: 799 traceback.print_exc() 718 800 719 801 g_ImplementationHelper = unohelper.ImplementationHelper() 720 802 721 for cls in (OpenPLMLogin, OpenPLMCheckOut, OpenPLMDownload): 803 for cls in (OpenPLMLogin, OpenPLMCheckOut, OpenPLMDownload, OpenPLMForget, 804 OpenPLMCheckIn): 722 805 g_ImplementationHelper.addImplementation(cls, 723 806 'org.example.%s' % cls.__name__,
Note: See TracChangeset
for help on using the changeset viewer.