1*a1b4a26bSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*a1b4a26bSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*a1b4a26bSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*a1b4a26bSAndrew Rist * distributed with this work for additional information 6*a1b4a26bSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*a1b4a26bSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*a1b4a26bSAndrew Rist * "License"); you may not use this file except in compliance 9*a1b4a26bSAndrew Rist * with the License. You may obtain a copy of the License at 10*a1b4a26bSAndrew Rist * 11*a1b4a26bSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*a1b4a26bSAndrew Rist * 13*a1b4a26bSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*a1b4a26bSAndrew Rist * software distributed under the License is distributed on an 15*a1b4a26bSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*a1b4a26bSAndrew Rist * KIND, either express or implied. See the License for the 17*a1b4a26bSAndrew Rist * specific language governing permissions and limitations 18*a1b4a26bSAndrew Rist * under the License. 19*a1b4a26bSAndrew Rist * 20*a1b4a26bSAndrew Rist *************************************************************/ 21*a1b4a26bSAndrew Rist 22*a1b4a26bSAndrew Rist 23cdf0e10cSrcweir package com.sun.star.wizards.web; 24cdf0e10cSrcweir 25cdf0e10cSrcweir import javax.swing.ListModel; 26cdf0e10cSrcweir 27cdf0e10cSrcweir import com.sun.star.awt.KeyEvent; 28cdf0e10cSrcweir import com.sun.star.awt.XControl; 29cdf0e10cSrcweir import com.sun.star.awt.XKeyListener; 30cdf0e10cSrcweir import com.sun.star.awt.XWindow; 31cdf0e10cSrcweir import com.sun.star.container.NoSuchElementException; 32cdf0e10cSrcweir import com.sun.star.lang.EventObject; 33cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory; 34cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime; 35cdf0e10cSrcweir import com.sun.star.util.XCloseable; 36cdf0e10cSrcweir import com.sun.star.wizards.common.Configuration; 37cdf0e10cSrcweir import com.sun.star.wizards.common.FileAccess; 38cdf0e10cSrcweir import com.sun.star.wizards.common.Helper; 39cdf0e10cSrcweir import com.sun.star.wizards.common.JavaTools; 40cdf0e10cSrcweir import com.sun.star.wizards.common.SystemDialog; 41cdf0e10cSrcweir import com.sun.star.wizards.common.PropertyNames; 42cdf0e10cSrcweir import com.sun.star.wizards.ui.UnoDialog; 43cdf0e10cSrcweir import com.sun.star.wizards.ui.event.DataAware; 44cdf0e10cSrcweir import com.sun.star.wizards.ui.event.ListModelBinder; 45cdf0e10cSrcweir import com.sun.star.wizards.ui.event.Task; 46cdf0e10cSrcweir import com.sun.star.wizards.web.data.CGDocument; 47cdf0e10cSrcweir import com.sun.star.wizards.web.data.CGPublish; 48cdf0e10cSrcweir import com.sun.star.wizards.web.data.CGSession; 49cdf0e10cSrcweir import com.sun.star.wizards.web.data.CGSessionName; 50cdf0e10cSrcweir 51cdf0e10cSrcweir /** 52cdf0e10cSrcweir * This class implements the ui-events of the 53cdf0e10cSrcweir * web wizard. 54cdf0e10cSrcweir * it is therfore sorted to steps. 55cdf0e10cSrcweir * not much application-logic here - just plain 56cdf0e10cSrcweir * methods which react to events. 57cdf0e10cSrcweir * The only exception are the finish methods with the save 58cdf0e10cSrcweir * session methods. 59cdf0e10cSrcweir */ 60cdf0e10cSrcweir public abstract class WWD_Events extends WWD_Startup 61cdf0e10cSrcweir { 62cdf0e10cSrcweir 63cdf0e10cSrcweir private static final short[] EMPTY_SHORT_ARRAY = new short[0]; 64cdf0e10cSrcweir /** 65cdf0e10cSrcweir * Tracks the current loaded session. 66cdf0e10cSrcweir * If PropertyNames.EMPTY_STRING - it means the current session is the default one (empty) 67cdf0e10cSrcweir * If a session is loaded, this will be the name of the loaded session. 68cdf0e10cSrcweir */ 69cdf0e10cSrcweir protected String currentSession = PropertyNames.EMPTY_STRING; 70cdf0e10cSrcweir 71cdf0e10cSrcweir /** 72cdf0e10cSrcweir * He - my constructor ! 73cdf0e10cSrcweir * I add a window listener, which, when 74cdf0e10cSrcweir * the window closes, deltes the temp directory. 75cdf0e10cSrcweir */ WWD_Events(XMultiServiceFactory xmsf)76cdf0e10cSrcweir public WWD_Events(XMultiServiceFactory xmsf) throws Exception 77cdf0e10cSrcweir { 78cdf0e10cSrcweir super(xmsf); 79cdf0e10cSrcweir Create c = new Create(); 80cdf0e10cSrcweir XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, chkFTP); 81cdf0e10cSrcweir xWindow.addKeyListener(c); 82cdf0e10cSrcweir xWindow = UnoRuntime.queryInterface(XWindow.class, chkLocalDir); 83cdf0e10cSrcweir xWindow.addKeyListener(c); 84cdf0e10cSrcweir xWindow = UnoRuntime.queryInterface(XWindow.class, chkZip); 85cdf0e10cSrcweir xWindow.addKeyListener(c); 86cdf0e10cSrcweir } 87cdf0e10cSrcweir 88cdf0e10cSrcweir /* ********************************************************* 89cdf0e10cSrcweir * ******************************************************* 90cdf0e10cSrcweir * EVENT and UI METHODS 91cdf0e10cSrcweir * ******************************************************* 92cdf0e10cSrcweir * *********************************************************/ leaveStep(int nOldStep, int nNewStep)93cdf0e10cSrcweir protected void leaveStep(int nOldStep, int nNewStep) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir if (nOldStep == 1 && nNewStep == 2) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir // 1. check if the selected session is the same as the current one. 98cdf0e10cSrcweir } 99cdf0e10cSrcweir } 100cdf0e10cSrcweir enterStep(int old, int newStep)101cdf0e10cSrcweir protected void enterStep(int old, int newStep) 102cdf0e10cSrcweir { 103cdf0e10cSrcweir if ((old == 1)) 104cdf0e10cSrcweir { 105cdf0e10cSrcweir String sessionToLoad = PropertyNames.EMPTY_STRING; 106cdf0e10cSrcweir short[] s = (short[]) Helper.getUnoPropertyValue(getModel(lstLoadSettings), PropertyNames.SELECTED_ITEMS); 107cdf0e10cSrcweir if (s.length == 0 || s[0] == 0) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir sessionToLoad = PropertyNames.EMPTY_STRING; 110cdf0e10cSrcweir } 111cdf0e10cSrcweir else 112cdf0e10cSrcweir { 113cdf0e10cSrcweir sessionToLoad = ((CGSessionName) settings.cp_SavedSessions.getElementAt(s[0])).cp_Name; 114cdf0e10cSrcweir } 115cdf0e10cSrcweir if (!sessionToLoad.equals(currentSession)) 116cdf0e10cSrcweir { 117cdf0e10cSrcweir loadSession(sessionToLoad); 118cdf0e10cSrcweir } 119cdf0e10cSrcweir } 120cdf0e10cSrcweir if (newStep == 5) 121cdf0e10cSrcweir { 122cdf0e10cSrcweir } 123cdf0e10cSrcweir } 124cdf0e10cSrcweir 125cdf0e10cSrcweir /* ********************************* 126cdf0e10cSrcweir * STEP 1 127cdf0e10cSrcweir */ 128cdf0e10cSrcweir /** 129cdf0e10cSrcweir * Called from the Uno event dispatcher when the 130cdf0e10cSrcweir * user selects a saved session. 131cdf0e10cSrcweir */ sessionSelected()132cdf0e10cSrcweir public void sessionSelected() 133cdf0e10cSrcweir { 134cdf0e10cSrcweir short[] s = (short[]) Helper.getUnoPropertyValue(getModel(lstLoadSettings), PropertyNames.SELECTED_ITEMS); 135cdf0e10cSrcweir setEnabled(btnDelSession, s.length > 0 && s[0] > 0); 136cdf0e10cSrcweir } 137cdf0e10cSrcweir 138cdf0e10cSrcweir /** 139cdf0e10cSrcweir * Ha ! the session should be loaded :-) 140cdf0e10cSrcweir */ loadSession(final String sessionToLoad)141cdf0e10cSrcweir public void loadSession(final String sessionToLoad) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir try 144cdf0e10cSrcweir { 145cdf0e10cSrcweir final StatusDialog sd = getStatusDialog(); 146cdf0e10cSrcweir 147cdf0e10cSrcweir final Task task = new Task("LoadDocs", PropertyNames.EMPTY_STRING, 10); 148cdf0e10cSrcweir 149cdf0e10cSrcweir sd.execute(this, task, resources.resLoadingSession); 150cdf0e10cSrcweir task.start(); 151cdf0e10cSrcweir 152cdf0e10cSrcweir setSelectedDoc(EMPTY_SHORT_ARRAY); 153cdf0e10cSrcweir Helper.setUnoPropertyValue(getModel(lstDocuments), PropertyNames.SELECTED_ITEMS, EMPTY_SHORT_ARRAY); 154cdf0e10cSrcweir Helper.setUnoPropertyValue(getModel(lstDocuments), PropertyNames.STRING_ITEM_LIST, EMPTY_STRING_ARRAY); 155cdf0e10cSrcweir 156cdf0e10cSrcweir Object view = null; 157cdf0e10cSrcweir 158cdf0e10cSrcweir if (sessionToLoad.equals(PropertyNames.EMPTY_STRING)) 159cdf0e10cSrcweir { 160cdf0e10cSrcweir view = Configuration.getConfigurationRoot(xMSF, CONFIG_PATH + "/DefaultSession", false); 161cdf0e10cSrcweir } 162cdf0e10cSrcweir else 163cdf0e10cSrcweir { 164cdf0e10cSrcweir view = Configuration.getConfigurationRoot(xMSF, CONFIG_PATH + "/SavedSessions", false); 165cdf0e10cSrcweir view = Configuration.getNode(sessionToLoad, view); 166cdf0e10cSrcweir } 167cdf0e10cSrcweir 168cdf0e10cSrcweir CGSession session = new CGSession(); 169cdf0e10cSrcweir session.setRoot(settings); 170cdf0e10cSrcweir session.readConfiguration(view, CONFIG_READ_PARAM); 171cdf0e10cSrcweir task.setMax(session.cp_Content.cp_Documents.getSize() * 5 + 7); 172cdf0e10cSrcweir task.advance(true); 173cdf0e10cSrcweir 174cdf0e10cSrcweir if (sessionToLoad.equals(PropertyNames.EMPTY_STRING)) 175cdf0e10cSrcweir { 176cdf0e10cSrcweir setSaveSessionName(session); 177cdf0e10cSrcweir } 178cdf0e10cSrcweir mount(session, task, false, sd.xControl); 179cdf0e10cSrcweir 180cdf0e10cSrcweir checkSteps(); 181cdf0e10cSrcweir currentSession = sessionToLoad; 182cdf0e10cSrcweir 183cdf0e10cSrcweir while (task.getStatus() <= task.getMax()) 184cdf0e10cSrcweir { 185cdf0e10cSrcweir task.advance(false); 186cdf0e10cSrcweir } 187cdf0e10cSrcweir task.removeTaskListener(sd); 188cdf0e10cSrcweir } 189cdf0e10cSrcweir catch (Exception ex) 190cdf0e10cSrcweir { 191cdf0e10cSrcweir unexpectedError(ex); 192cdf0e10cSrcweir } 193cdf0e10cSrcweir 194cdf0e10cSrcweir try 195cdf0e10cSrcweir { 196cdf0e10cSrcweir refreshStylePreview(); 197cdf0e10cSrcweir updateIconsetText(); 198cdf0e10cSrcweir } 199cdf0e10cSrcweir catch (Exception e) 200cdf0e10cSrcweir { 201cdf0e10cSrcweir // TODO Auto-generated catch block 202cdf0e10cSrcweir e.printStackTrace(); 203cdf0e10cSrcweir } 204cdf0e10cSrcweir } 205cdf0e10cSrcweir 206cdf0e10cSrcweir /** 207cdf0e10cSrcweir * hmm. the user clicked the delete button. 208cdf0e10cSrcweir */ delSession()209cdf0e10cSrcweir public void delSession() 210cdf0e10cSrcweir { 211cdf0e10cSrcweir short[] selected = (short[]) Helper.getUnoPropertyValue(getModel(lstLoadSettings), PropertyNames.SELECTED_ITEMS); 212cdf0e10cSrcweir if (selected.length == 0) 213cdf0e10cSrcweir { 214cdf0e10cSrcweir return; 215cdf0e10cSrcweir } 216cdf0e10cSrcweir if (selected[0] == 0) 217cdf0e10cSrcweir { 218cdf0e10cSrcweir return; 219cdf0e10cSrcweir } 220cdf0e10cSrcweir boolean confirm = AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(), resources.resDelSessionConfirm, ErrorHandler.ERROR_QUESTION_NO); 221cdf0e10cSrcweir if (confirm) 222cdf0e10cSrcweir { 223cdf0e10cSrcweir try 224cdf0e10cSrcweir { 225cdf0e10cSrcweir String name = (String) settings.cp_SavedSessions.getKey(selected[0]); 226cdf0e10cSrcweir // first delete the session from the registry/configuration. 227cdf0e10cSrcweir 228cdf0e10cSrcweir Configuration.removeNode(xMSF, CONFIG_PATH + "/SavedSessions", name); 229cdf0e10cSrcweir 230cdf0e10cSrcweir // then delete the session from the java-set (settings.cp_SavedSessions) 231cdf0e10cSrcweir settings.cp_SavedSessions.remove(selected[0]); 232cdf0e10cSrcweir settings.savedSessions.remove(selected[0] - 1); 233cdf0e10cSrcweir 234cdf0e10cSrcweir short[] nextSelected = new short[] 235cdf0e10cSrcweir { 236cdf0e10cSrcweir (short) 0 237cdf0e10cSrcweir }; 238cdf0e10cSrcweir // We try to select the same item index again, if possible 239cdf0e10cSrcweir if (settings.cp_SavedSessions.getSize() > selected[0]) 240cdf0e10cSrcweir { 241cdf0e10cSrcweir nextSelected[0] = selected[0]; 242cdf0e10cSrcweir } 243cdf0e10cSrcweir else 244cdf0e10cSrcweir // this will always be available because 245cdf0e10cSrcweir // the user can not remove item 0. 246cdf0e10cSrcweir { 247cdf0e10cSrcweir nextSelected[0] = (short) (selected[0] - 1); // if the <none> session will be selected, disable the remove button... 248cdf0e10cSrcweir } 249cdf0e10cSrcweir if (nextSelected[0] == 0) 250cdf0e10cSrcweir { 251cdf0e10cSrcweir Helper.setUnoPropertyValue(getModel(btnDelSession), PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); // select... 252cdf0e10cSrcweir } 253cdf0e10cSrcweir Helper.setUnoPropertyValue(getModel(lstLoadSettings), PropertyNames.SELECTED_ITEMS, nextSelected); 254cdf0e10cSrcweir 255cdf0e10cSrcweir //ListModelBinder.fillComboBox(cbSaveSettings, settings.savedSessions.items(), null); 256cdf0e10cSrcweir 257cdf0e10cSrcweir 258cdf0e10cSrcweir } 259cdf0e10cSrcweir catch (Exception ex) 260cdf0e10cSrcweir { 261cdf0e10cSrcweir ex.printStackTrace(); 262cdf0e10cSrcweir unexpectedError(ex); 263cdf0e10cSrcweir } 264cdf0e10cSrcweir } 265cdf0e10cSrcweir } 266cdf0e10cSrcweir 267cdf0e10cSrcweir /* ******************************** 268cdf0e10cSrcweir * STEP 2 269cdf0e10cSrcweir */ 270cdf0e10cSrcweir /** 271cdf0e10cSrcweir * A method used by the UnoDataAware attached 272cdf0e10cSrcweir * to the Documents listbox. 273cdf0e10cSrcweir * See the concept of the DataAware objects to undestand 274cdf0e10cSrcweir * why it is there... 275cdf0e10cSrcweir */ getSelectedDoc()276cdf0e10cSrcweir public short[] getSelectedDoc() 277cdf0e10cSrcweir { 278cdf0e10cSrcweir return selectedDoc; 279cdf0e10cSrcweir } 280cdf0e10cSrcweir private static String[] EMPTY_STRING_ARRAY = new String[0]; 281cdf0e10cSrcweir 282cdf0e10cSrcweir /* public void loadSessionSelected() { 283cdf0e10cSrcweir UIHelper.setEnabled(btnLoadSession,true); 284cdf0e10cSrcweir UIHelper.setEnabled(btnDelSession,true); 285cdf0e10cSrcweir } 286cdf0e10cSrcweir */ 287cdf0e10cSrcweir /** 288cdf0e10cSrcweir * when the user clicks another document 289cdf0e10cSrcweir * in the listbox, this method is called, 290cdf0e10cSrcweir * and couses the display in 291cdf0e10cSrcweir * the textboxes title,description, author and export format 292cdf0e10cSrcweir * to change 293cdf0e10cSrcweir */ setSelectedDoc(short[] s)294cdf0e10cSrcweir public void setSelectedDoc(short[] s) 295cdf0e10cSrcweir { 296cdf0e10cSrcweir CGDocument oldDoc = getDoc(selectedDoc); 297cdf0e10cSrcweir CGDocument doc = getDoc(s); 298cdf0e10cSrcweir 299cdf0e10cSrcweir if (doc == null) 300cdf0e10cSrcweir { 301cdf0e10cSrcweir fillExportList(EMPTY_STRING_ARRAY); 302cdf0e10cSrcweir //I try to avoid refreshing the export list if 303cdf0e10cSrcweir //the same type of document is chosen. 304cdf0e10cSrcweir } 305cdf0e10cSrcweir else if (oldDoc == null || (!oldDoc.appType.equals(doc.appType))) 306cdf0e10cSrcweir { 307cdf0e10cSrcweir fillExportList(settings.getExporters(doc.appType)); 308cdf0e10cSrcweir } 309cdf0e10cSrcweir 310cdf0e10cSrcweir 311cdf0e10cSrcweir selectedDoc = s; 312cdf0e10cSrcweir 313cdf0e10cSrcweir mount(doc, docAware); 314cdf0e10cSrcweir disableDocUpDown(); 315cdf0e10cSrcweir } 316cdf0e10cSrcweir 317cdf0e10cSrcweir /** 318cdf0e10cSrcweir * The user clicks the "Add" button. 319cdf0e10cSrcweir * This will open a "FileOpen" dialog, 320cdf0e10cSrcweir * and, if the user chooses more than one file, 321cdf0e10cSrcweir * will open a status dialog, when validating each document. 322cdf0e10cSrcweir */ addDocument()323cdf0e10cSrcweir public void addDocument() 324cdf0e10cSrcweir { 325cdf0e10cSrcweir 326cdf0e10cSrcweir final String[] files = getDocAddDialog().callOpenDialog(true, settings.cp_DefaultSession.cp_InDirectory); 327cdf0e10cSrcweir if (files == null) 328cdf0e10cSrcweir { 329cdf0e10cSrcweir return; 330cdf0e10cSrcweir } 331cdf0e10cSrcweir final Task task = new Task(PropertyNames.EMPTY_STRING, PropertyNames.EMPTY_STRING, files.length * 5); 332cdf0e10cSrcweir 333cdf0e10cSrcweir /* 334cdf0e10cSrcweir * If more than a certain number 335cdf0e10cSrcweir * of documents have been added, 336cdf0e10cSrcweir * open the status dialog. 337cdf0e10cSrcweir */ 338cdf0e10cSrcweir if (files.length > MIN_ADD_FILES_FOR_DIALOG) 339cdf0e10cSrcweir { 340cdf0e10cSrcweir StatusDialog sd = getStatusDialog(); 341cdf0e10cSrcweir sd.setLabel(resources.resValidatingDocuments); 342cdf0e10cSrcweir sd.execute(this, task, resources.prodName); // new LoadDocs( sd.xControl, files, task ) 343cdf0e10cSrcweir LoadDocs oLoadDocs = new LoadDocs(this.xControl, files, task); 344cdf0e10cSrcweir oLoadDocs.loadDocuments(); 345cdf0e10cSrcweir task.removeTaskListener(sd); 346cdf0e10cSrcweir } 347cdf0e10cSrcweir /* 348cdf0e10cSrcweir * When adding a single document, do not use a 349cdf0e10cSrcweir * status dialog... 350cdf0e10cSrcweir */ 351cdf0e10cSrcweir else 352cdf0e10cSrcweir { 353cdf0e10cSrcweir LoadDocs oLoadDocs = new LoadDocs(this.xControl, files, task); 354cdf0e10cSrcweir oLoadDocs.loadDocuments(); 355cdf0e10cSrcweir } 356cdf0e10cSrcweir 357cdf0e10cSrcweir } 358cdf0e10cSrcweir 359cdf0e10cSrcweir /** 360cdf0e10cSrcweir * The user clicked delete. 361cdf0e10cSrcweir */ removeDocument()362cdf0e10cSrcweir public void removeDocument() 363cdf0e10cSrcweir { 364cdf0e10cSrcweir if (selectedDoc.length == 0) 365cdf0e10cSrcweir { 366cdf0e10cSrcweir return; 367cdf0e10cSrcweir } 368cdf0e10cSrcweir settings.cp_DefaultSession.cp_Content.cp_Documents.remove(selectedDoc[0]); 369cdf0e10cSrcweir 370cdf0e10cSrcweir // update the selected document 371cdf0e10cSrcweir while (selectedDoc[0] >= getDocsCount()) 372cdf0e10cSrcweir { 373cdf0e10cSrcweir selectedDoc[0]--; // if there are no documents... 374cdf0e10cSrcweir } 375cdf0e10cSrcweir if (selectedDoc[0] == -1) 376cdf0e10cSrcweir { 377cdf0e10cSrcweir selectedDoc = EMPTY_SHORT_ARRAY; // update the list to show the right selection. 378cdf0e10cSrcweir } 379cdf0e10cSrcweir docListDA.updateUI(); 380cdf0e10cSrcweir // disables all the next steps, if the list of docuemnts 381cdf0e10cSrcweir // is empty. 382cdf0e10cSrcweir checkSteps(); 383cdf0e10cSrcweir } 384cdf0e10cSrcweir 385cdf0e10cSrcweir /** 386cdf0e10cSrcweir * doc up. 387cdf0e10cSrcweir */ docUp()388cdf0e10cSrcweir public void docUp() 389cdf0e10cSrcweir { 390cdf0e10cSrcweir Object doc = settings.cp_DefaultSession.cp_Content.cp_Documents.getElementAt(selectedDoc[0]); 391cdf0e10cSrcweir settings.cp_DefaultSession.cp_Content.cp_Documents.remove(selectedDoc[0]); 392cdf0e10cSrcweir settings.cp_DefaultSession.cp_Content.cp_Documents.add(--selectedDoc[0], doc); 393cdf0e10cSrcweir docListDA.updateUI(); 394cdf0e10cSrcweir disableDocUpDown(); 395cdf0e10cSrcweir } 396cdf0e10cSrcweir 397cdf0e10cSrcweir /** 398cdf0e10cSrcweir * doc down 399cdf0e10cSrcweir */ docDown()400cdf0e10cSrcweir public void docDown() 401cdf0e10cSrcweir { 402cdf0e10cSrcweir Object doc = settings.cp_DefaultSession.cp_Content.cp_Documents.getElementAt(selectedDoc[0]); 403cdf0e10cSrcweir settings.cp_DefaultSession.cp_Content.cp_Documents.remove(selectedDoc[0]); 404cdf0e10cSrcweir settings.cp_DefaultSession.cp_Content.cp_Documents.add(++selectedDoc[0], doc); 405cdf0e10cSrcweir docListDA.updateUI(); 406cdf0e10cSrcweir disableDocUpDown(); 407cdf0e10cSrcweir } 408cdf0e10cSrcweir 409cdf0e10cSrcweir /* ****************************** 410cdf0e10cSrcweir * STEP 5 411cdf0e10cSrcweir */ 412cdf0e10cSrcweir /** 413cdf0e10cSrcweir * invoked when the user clicks "Choose backgrounds" button. 414cdf0e10cSrcweir */ 415cdf0e10cSrcweir private ImageListDialog bgDialog; 416cdf0e10cSrcweir 417cdf0e10cSrcweir /** 418cdf0e10cSrcweir * the user clicked the "backgrounds" button 419cdf0e10cSrcweir */ chooseBackground()420cdf0e10cSrcweir public void chooseBackground() 421cdf0e10cSrcweir { 422cdf0e10cSrcweir try 423cdf0e10cSrcweir { 424cdf0e10cSrcweir setEnabled(btnBackgrounds, false); 425cdf0e10cSrcweir if (bgDialog == null) 426cdf0e10cSrcweir { 427cdf0e10cSrcweir bgDialog = new BackgroundsDialog(xMSF, settings.cp_BackgroundImages, resources); 428cdf0e10cSrcweir bgDialog.createWindowPeer(xControl.getPeer()); 429cdf0e10cSrcweir } 430cdf0e10cSrcweir bgDialog.setSelected(settings.cp_DefaultSession.cp_Design.cp_BackgroundImage); 431cdf0e10cSrcweir short i = bgDialog.executeDialog((UnoDialog) WWD_Events.this); 432cdf0e10cSrcweir if (i == 1) //ok 433cdf0e10cSrcweir { 434cdf0e10cSrcweir setBackground(bgDialog.getSelected()); 435cdf0e10cSrcweir } 436cdf0e10cSrcweir } 437cdf0e10cSrcweir catch (Exception ex) 438cdf0e10cSrcweir { 439cdf0e10cSrcweir ex.printStackTrace(); 440cdf0e10cSrcweir } 441cdf0e10cSrcweir finally 442cdf0e10cSrcweir { 443cdf0e10cSrcweir setEnabled(btnBackgrounds, true); 444cdf0e10cSrcweir } 445cdf0e10cSrcweir } 446cdf0e10cSrcweir 447cdf0e10cSrcweir /** 448cdf0e10cSrcweir * invoked when the BackgorundsDialog is "OKed". 449cdf0e10cSrcweir */ setBackground(Object background)450cdf0e10cSrcweir public void setBackground(Object background) 451cdf0e10cSrcweir { 452cdf0e10cSrcweir if (background == null) 453cdf0e10cSrcweir { 454cdf0e10cSrcweir background = PropertyNames.EMPTY_STRING; 455cdf0e10cSrcweir } 456cdf0e10cSrcweir settings.cp_DefaultSession.cp_Design.cp_BackgroundImage = (String) background; 457cdf0e10cSrcweir refreshStylePreview(); 458cdf0e10cSrcweir } 459cdf0e10cSrcweir private IconsDialog iconsDialog; 460cdf0e10cSrcweir 461cdf0e10cSrcweir /** 462cdf0e10cSrcweir * is called when the user clicks "Icon sets" button. 463cdf0e10cSrcweir * 464cdf0e10cSrcweir */ chooseIconset()465cdf0e10cSrcweir public void chooseIconset() 466cdf0e10cSrcweir { 467cdf0e10cSrcweir try 468cdf0e10cSrcweir { 469cdf0e10cSrcweir setEnabled(btnIconSets, false); 470cdf0e10cSrcweir if (iconsDialog == null) 471cdf0e10cSrcweir { 472cdf0e10cSrcweir iconsDialog = new IconsDialog(xMSF, settings.cp_IconSets, resources); 473cdf0e10cSrcweir iconsDialog.createWindowPeer(xControl.getPeer()); 474cdf0e10cSrcweir } 475cdf0e10cSrcweir 476cdf0e10cSrcweir iconsDialog.setIconset(settings.cp_DefaultSession.cp_Design.cp_IconSet); 477cdf0e10cSrcweir 478cdf0e10cSrcweir short i = iconsDialog.executeDialog((UnoDialog) WWD_Events.this); 479cdf0e10cSrcweir if (i == 1) //ok 480cdf0e10cSrcweir { 481cdf0e10cSrcweir setIconset(iconsDialog.getIconset()); 482cdf0e10cSrcweir } 483cdf0e10cSrcweir } 484cdf0e10cSrcweir catch (Exception ex) 485cdf0e10cSrcweir { 486cdf0e10cSrcweir ex.printStackTrace(); 487cdf0e10cSrcweir } 488cdf0e10cSrcweir finally 489cdf0e10cSrcweir { 490cdf0e10cSrcweir setEnabled(btnIconSets, true); 491cdf0e10cSrcweir } 492cdf0e10cSrcweir } 493cdf0e10cSrcweir 494cdf0e10cSrcweir /** 495cdf0e10cSrcweir * invoked when the Iconsets Dialog is OKed. 496cdf0e10cSrcweir */ setIconset(String icon)497cdf0e10cSrcweir public void setIconset(String icon) 498cdf0e10cSrcweir { 499cdf0e10cSrcweir settings.cp_DefaultSession.cp_Design.cp_IconSet = icon; 500cdf0e10cSrcweir updateIconsetText(); 501cdf0e10cSrcweir } 502cdf0e10cSrcweir 503cdf0e10cSrcweir /* ****************************** 504cdf0e10cSrcweir * STEP 7 505cdf0e10cSrcweir */ 506cdf0e10cSrcweir /** 507cdf0e10cSrcweir * sets the publishing url of either a local/zip or ftp publisher. 508cdf0e10cSrcweir * updates the ui.... 509cdf0e10cSrcweir */ setPublishUrl(String publisher, String url, int number)510cdf0e10cSrcweir private CGPublish setPublishUrl(String publisher, String url, int number) 511cdf0e10cSrcweir { 512cdf0e10cSrcweir if (url == null) 513cdf0e10cSrcweir { 514cdf0e10cSrcweir return null; 515cdf0e10cSrcweir } 516cdf0e10cSrcweir CGPublish p = getPublisher(publisher); 517cdf0e10cSrcweir p.cp_URL = url; 518cdf0e10cSrcweir p.cp_Publish = true; 519cdf0e10cSrcweir updatePublishUI(number); 520cdf0e10cSrcweir p.overwriteApproved = true; 521cdf0e10cSrcweir return p; 522cdf0e10cSrcweir } 523cdf0e10cSrcweir 524cdf0e10cSrcweir /** 525cdf0e10cSrcweir * updates the ui of a certain publisher 526cdf0e10cSrcweir * (the text box url) 527cdf0e10cSrcweir * @param number 528cdf0e10cSrcweir */ updatePublishUI(int number)529cdf0e10cSrcweir private void updatePublishUI(int number) 530cdf0e10cSrcweir { 531cdf0e10cSrcweir ((DataAware) pubAware.get(number)).updateUI(); 532cdf0e10cSrcweir ((DataAware) pubAware.get(number + 1)).updateUI(); 533cdf0e10cSrcweir checkPublish(); 534cdf0e10cSrcweir } 535cdf0e10cSrcweir 536cdf0e10cSrcweir /** 537cdf0e10cSrcweir * The user clicks the local "..." button. 538cdf0e10cSrcweir * 539cdf0e10cSrcweir */ setPublishLocalDir()540cdf0e10cSrcweir public void setPublishLocalDir() 541cdf0e10cSrcweir { 542cdf0e10cSrcweir String dir = showFolderDialog("Local destination directory", PropertyNames.EMPTY_STRING, settings.cp_DefaultSession.cp_OutDirectory); 543cdf0e10cSrcweir //if ok was pressed... 544cdf0e10cSrcweir setPublishUrl(LOCAL_PUBLISHER, dir, 0); 545cdf0e10cSrcweir 546cdf0e10cSrcweir } 547cdf0e10cSrcweir 548cdf0e10cSrcweir /** 549cdf0e10cSrcweir * The user clicks the "Configure" FTP button. 550cdf0e10cSrcweir * 551cdf0e10cSrcweir */ setFTPPublish()552cdf0e10cSrcweir public void setFTPPublish() 553cdf0e10cSrcweir { 554cdf0e10cSrcweir if (showFTPDialog(getPublisher(FTP_PUBLISHER))) 555cdf0e10cSrcweir { 556cdf0e10cSrcweir getPublisher(FTP_PUBLISHER).cp_Publish = true; 557cdf0e10cSrcweir updatePublishUI(2); 558cdf0e10cSrcweir } 559cdf0e10cSrcweir } 560cdf0e10cSrcweir 561cdf0e10cSrcweir /** 562cdf0e10cSrcweir * show the ftp dialog 563cdf0e10cSrcweir * @param pub 564cdf0e10cSrcweir * @return true if OK was pressed, otherwise false. 565cdf0e10cSrcweir */ showFTPDialog(CGPublish pub)566cdf0e10cSrcweir private boolean showFTPDialog(CGPublish pub) 567cdf0e10cSrcweir { 568cdf0e10cSrcweir try 569cdf0e10cSrcweir { 570cdf0e10cSrcweir return getFTPDialog(pub).execute(this) == 1; 571cdf0e10cSrcweir } 572cdf0e10cSrcweir catch (Exception ex) 573cdf0e10cSrcweir { 574cdf0e10cSrcweir ex.printStackTrace(); 575cdf0e10cSrcweir return false; 576cdf0e10cSrcweir } 577cdf0e10cSrcweir } 578cdf0e10cSrcweir 579cdf0e10cSrcweir /** 580cdf0e10cSrcweir * the user clicks the zip "..." button. 581cdf0e10cSrcweir * Choose a zip file... 582cdf0e10cSrcweir */ setZipFilename()583cdf0e10cSrcweir public void setZipFilename() 584cdf0e10cSrcweir { 585cdf0e10cSrcweir SystemDialog sd = getZipDialog(); 586cdf0e10cSrcweir String zipFile = sd.callStoreDialog(settings.cp_DefaultSession.cp_OutDirectory, resources.resDefaultArchiveFilename); 587cdf0e10cSrcweir setPublishUrl(ZIP_PUBLISHER, zipFile, 4); 588cdf0e10cSrcweir getPublisher(ZIP_PUBLISHER).overwriteApproved = true; 589cdf0e10cSrcweir } 590cdf0e10cSrcweir private TOCPreview docPreview; 591cdf0e10cSrcweir 592cdf0e10cSrcweir /** 593cdf0e10cSrcweir * the user clicks the "Preview" button. 594cdf0e10cSrcweir */ documentPreview()595cdf0e10cSrcweir public void documentPreview() 596cdf0e10cSrcweir { 597cdf0e10cSrcweir try 598cdf0e10cSrcweir { 599cdf0e10cSrcweir if (docPreview == null) 600cdf0e10cSrcweir { 601cdf0e10cSrcweir docPreview = new TOCPreview(xMSF, settings, resources, stylePreview.tempDir, myFrame); 602cdf0e10cSrcweir } 603cdf0e10cSrcweir docPreview.refresh(settings); 604cdf0e10cSrcweir } 605cdf0e10cSrcweir catch (Exception ex) 606cdf0e10cSrcweir { 607cdf0e10cSrcweir unexpectedError(ex); 608cdf0e10cSrcweir } 609cdf0e10cSrcweir } 610cdf0e10cSrcweir 611cdf0e10cSrcweir /* ********************** 612cdf0e10cSrcweir * FINISH 613cdf0e10cSrcweir */ 614cdf0e10cSrcweir /** 615cdf0e10cSrcweir * This method checks if the given target's path, added the pathExtension argument, 616cdf0e10cSrcweir * exists, and asks the user what to do about it. 617cdf0e10cSrcweir * If the user says its all fine, then the target will 618cdf0e10cSrcweir * be replaced. 619cdf0e10cSrcweir * @return true if "create" should continue. false if "create" should abort. 620cdf0e10cSrcweir */ publishTargetApproved()621cdf0e10cSrcweir private boolean publishTargetApproved() 622cdf0e10cSrcweir { 623cdf0e10cSrcweir boolean result = true; 624cdf0e10cSrcweir // 1. check local publish target 625cdf0e10cSrcweir 626cdf0e10cSrcweir CGPublish p = getPublisher(LOCAL_PUBLISHER); 627cdf0e10cSrcweir 628cdf0e10cSrcweir // should publish ? 629cdf0e10cSrcweir if (p.cp_Publish) 630cdf0e10cSrcweir { 631cdf0e10cSrcweir String path = getFileAccess().getPath(p.url, null); 632cdf0e10cSrcweir // target exists? 633cdf0e10cSrcweir if (getFileAccess().exists(p.url, false)) 634cdf0e10cSrcweir { 635cdf0e10cSrcweir //if its a directory 636cdf0e10cSrcweir if (getFileAccess().isDirectory(p.url)) 637cdf0e10cSrcweir { 638cdf0e10cSrcweir //check if its empty 639cdf0e10cSrcweir String[] files = getFileAccess().listFiles(p.url, true); 640cdf0e10cSrcweir if (files.length > 0) 641cdf0e10cSrcweir { 642cdf0e10cSrcweir /* it is not empty :-( 643cdf0e10cSrcweir * it either a local publisher or an ftp (zip uses no directories 644cdf0e10cSrcweir * as target...) 645cdf0e10cSrcweir */ 646cdf0e10cSrcweir String message = JavaTools.replaceSubString(resources.resLocalTragetNotEmpty, 647cdf0e10cSrcweir path, "%FILENAME"); 648cdf0e10cSrcweir result = AbstractErrorHandler.showMessage( 649cdf0e10cSrcweir xMSF, xControl.getPeer(), message, 650cdf0e10cSrcweir ErrorHandler.MESSAGE_WARNING, ErrorHandler.BUTTONS_YES_NO, 651cdf0e10cSrcweir ErrorHandler.DEF_NO, ErrorHandler.RESULT_YES); 652cdf0e10cSrcweir 653cdf0e10cSrcweir if (!result) 654cdf0e10cSrcweir { 655cdf0e10cSrcweir return result; 656cdf0e10cSrcweir } 657cdf0e10cSrcweir } 658cdf0e10cSrcweir } 659cdf0e10cSrcweir else 660cdf0e10cSrcweir {//not a directory, but still exists 661cdf0e10cSrcweir String message = JavaTools.replaceSubString(resources.resLocalTargetExistsAsfile, 662cdf0e10cSrcweir path, "%FILENAME"); 663cdf0e10cSrcweir AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(), message, ErrorHandler.ERROR_PROCESS_FATAL); 664cdf0e10cSrcweir return false; 665cdf0e10cSrcweir } 666cdf0e10cSrcweir 667cdf0e10cSrcweir // try to write to the path... 668cdf0e10cSrcweir } 669cdf0e10cSrcweir else 670cdf0e10cSrcweir { 671cdf0e10cSrcweir // the local target directory does not exist. 672cdf0e10cSrcweir String message = JavaTools.replaceSubString(resources.resLocalTargetCreate, 673cdf0e10cSrcweir path, "%FILENAME"); 674cdf0e10cSrcweir try 675cdf0e10cSrcweir { 676cdf0e10cSrcweir result = AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(), message, 677cdf0e10cSrcweir ErrorHandler.ERROR_QUESTION_YES); 678cdf0e10cSrcweir } 679cdf0e10cSrcweir catch (Exception ex) 680cdf0e10cSrcweir { 681cdf0e10cSrcweir ex.printStackTrace(); 682cdf0e10cSrcweir } 683cdf0e10cSrcweir 684cdf0e10cSrcweir if (!result) 685cdf0e10cSrcweir { 686cdf0e10cSrcweir return result; 687cdf0e10cSrcweir // try to create the directory... 688cdf0e10cSrcweir } 689cdf0e10cSrcweir try 690cdf0e10cSrcweir { 691cdf0e10cSrcweir getFileAccess().fileAccess.createFolder(p.cp_URL); 692cdf0e10cSrcweir } 693cdf0e10cSrcweir catch (Exception ex) 694cdf0e10cSrcweir { 695cdf0e10cSrcweir message = JavaTools.replaceSubString(resources.resLocalTargetCouldNotCreate, 696cdf0e10cSrcweir path, "%FILENAME"); 697cdf0e10cSrcweir AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(), message, 698cdf0e10cSrcweir ErrorHandler.ERROR_PROCESS_FATAL); 699cdf0e10cSrcweir return false; 700cdf0e10cSrcweir } 701cdf0e10cSrcweir } 702cdf0e10cSrcweir } 703cdf0e10cSrcweir 704cdf0e10cSrcweir // 2. Check ZIP 705cdf0e10cSrcweir // should publish ? 706cdf0e10cSrcweir p = getPublisher(ZIP_PUBLISHER); 707cdf0e10cSrcweir 708cdf0e10cSrcweir if (p.cp_Publish) 709cdf0e10cSrcweir { 710cdf0e10cSrcweir 711cdf0e10cSrcweir String path = getFileAccess().getPath(p.cp_URL, null); 712cdf0e10cSrcweir // target exists? 713cdf0e10cSrcweir if (getFileAccess().exists(p.cp_URL, false)) 714cdf0e10cSrcweir { 715cdf0e10cSrcweir //if its a directory 716cdf0e10cSrcweir if (getFileAccess().isDirectory(p.cp_URL)) 717cdf0e10cSrcweir { 718cdf0e10cSrcweir String message = JavaTools.replaceSubString(resources.resZipTargetIsDir, 719cdf0e10cSrcweir path, "%FILENAME"); 720cdf0e10cSrcweir AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(), message, 721cdf0e10cSrcweir ErrorHandler.ERROR_PROCESS_FATAL); 722cdf0e10cSrcweir return false; 723cdf0e10cSrcweir } 724cdf0e10cSrcweir else 725cdf0e10cSrcweir {//not a directory, but still exists ( a file...) 726cdf0e10cSrcweir if (!p.overwriteApproved) 727cdf0e10cSrcweir { 728cdf0e10cSrcweir String message = JavaTools.replaceSubString(resources.resZipTargetExists, 729cdf0e10cSrcweir path, "%FILENAME"); 730cdf0e10cSrcweir result = AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(), message, 731cdf0e10cSrcweir ErrorHandler.ERROR_QUESTION_YES); 732cdf0e10cSrcweir if (!result) 733cdf0e10cSrcweir { 734cdf0e10cSrcweir return false; 735cdf0e10cSrcweir } 736cdf0e10cSrcweir } 737cdf0e10cSrcweir } 738cdf0e10cSrcweir } 739cdf0e10cSrcweir } 740cdf0e10cSrcweir 741cdf0e10cSrcweir // 3. check FTP 742cdf0e10cSrcweir p = getPublisher(FTP_PUBLISHER); 743cdf0e10cSrcweir 744cdf0e10cSrcweir // should publish ? 745cdf0e10cSrcweir if (p.cp_Publish) 746cdf0e10cSrcweir { 747cdf0e10cSrcweir 748cdf0e10cSrcweir String path = getFileAccess().getPath(p.cp_URL, null); 749cdf0e10cSrcweir 750cdf0e10cSrcweir // target exists? 751cdf0e10cSrcweir if (getFileAccess().exists(p.url, false)) 752cdf0e10cSrcweir { 753cdf0e10cSrcweir //if its a directory 754cdf0e10cSrcweir if (getFileAccess().isDirectory(p.url)) 755cdf0e10cSrcweir { 756cdf0e10cSrcweir //check if its empty 757cdf0e10cSrcweir String[] files = getFileAccess().listFiles(p.url, true); 758cdf0e10cSrcweir if (files.length > 0) 759cdf0e10cSrcweir { 760cdf0e10cSrcweir /* it is not empty :-( 761cdf0e10cSrcweir * it either a local publisher or an ftp (zip uses no directories 762cdf0e10cSrcweir * as target...) 763cdf0e10cSrcweir */ 764cdf0e10cSrcweir String message = JavaTools.replaceSubString(resources.resFTPTargetNotEmpty, 765cdf0e10cSrcweir path, "%FILENAME"); 766cdf0e10cSrcweir result = AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(), message, 767cdf0e10cSrcweir ErrorHandler.ERROR_QUESTION_CANCEL); 768cdf0e10cSrcweir if (!result) 769cdf0e10cSrcweir { 770cdf0e10cSrcweir return result; 771cdf0e10cSrcweir } 772cdf0e10cSrcweir } 773cdf0e10cSrcweir } 774cdf0e10cSrcweir else 775cdf0e10cSrcweir {//not a directory, but still exists (as a file) 776cdf0e10cSrcweir String message = JavaTools.replaceSubString(resources.resFTPTargetExistsAsfile, 777cdf0e10cSrcweir path, "%FILENAME"); 778cdf0e10cSrcweir AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(), message, 779cdf0e10cSrcweir ErrorHandler.ERROR_PROCESS_FATAL); 780cdf0e10cSrcweir return false; 781cdf0e10cSrcweir } 782cdf0e10cSrcweir 783cdf0e10cSrcweir // try to write to the path... 784cdf0e10cSrcweir } 785cdf0e10cSrcweir else 786cdf0e10cSrcweir { 787cdf0e10cSrcweir // the ftp target directory does not exist. 788cdf0e10cSrcweir String message = JavaTools.replaceSubString(resources.resFTPTargetCreate, 789cdf0e10cSrcweir path, "%FILENAME"); 790cdf0e10cSrcweir result = AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(), message, 791cdf0e10cSrcweir ErrorHandler.ERROR_QUESTION_YES); 792cdf0e10cSrcweir if (!result) 793cdf0e10cSrcweir { 794cdf0e10cSrcweir return result; 795cdf0e10cSrcweir // try to create the directory... 796cdf0e10cSrcweir } 797cdf0e10cSrcweir try 798cdf0e10cSrcweir { 799cdf0e10cSrcweir getFileAccess().fileAccess.createFolder(p.url); 800cdf0e10cSrcweir } 801cdf0e10cSrcweir catch (Exception ex) 802cdf0e10cSrcweir { 803cdf0e10cSrcweir message = JavaTools.replaceSubString(resources.resFTPTargetCouldNotCreate, 804cdf0e10cSrcweir path, "%FILENAME"); 805cdf0e10cSrcweir AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(), message, 806cdf0e10cSrcweir ErrorHandler.ERROR_PROCESS_FATAL); 807cdf0e10cSrcweir return false; 808cdf0e10cSrcweir } 809cdf0e10cSrcweir } 810cdf0e10cSrcweir } 811cdf0e10cSrcweir return true; 812cdf0e10cSrcweir } 813cdf0e10cSrcweir 814cdf0e10cSrcweir /* 815cdf0e10cSrcweir * return false if "create" should be aborted. true if everything is fine. 816cdf0e10cSrcweir */ saveSession()817cdf0e10cSrcweir private boolean saveSession() 818cdf0e10cSrcweir { 819cdf0e10cSrcweir try 820cdf0e10cSrcweir { 821cdf0e10cSrcweir Object node = null; 822cdf0e10cSrcweir String name = getSessionSaveName(); 823cdf0e10cSrcweir 824cdf0e10cSrcweir //set documents index field. 825cdf0e10cSrcweir ListModel docs = settings.cp_DefaultSession.cp_Content.cp_Documents; 826cdf0e10cSrcweir 827cdf0e10cSrcweir for (int i = 0; i < docs.getSize(); i++) 828cdf0e10cSrcweir { 829cdf0e10cSrcweir ((CGDocument) docs.getElementAt(i)).cp_Index = i; 830cdf0e10cSrcweir } 831cdf0e10cSrcweir Object conf = Configuration.getConfigurationRoot(xMSF, CONFIG_PATH + "/SavedSessions", true); 832cdf0e10cSrcweir // first I check if a session with the given name exists 833cdf0e10cSrcweir try 834cdf0e10cSrcweir { 835cdf0e10cSrcweir node = Configuration.getNode(name, conf); 836cdf0e10cSrcweir if (node != null) 837cdf0e10cSrcweir { 838cdf0e10cSrcweir if (!AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(), 839cdf0e10cSrcweir JavaTools.replaceSubString(resources.resSessionExists, name, "${NAME}"), 840cdf0e10cSrcweir ErrorHandler.ERROR_NORMAL_IGNORE)) 841cdf0e10cSrcweir { 842cdf0e10cSrcweir return false; //remove the old session 843cdf0e10cSrcweir } 844cdf0e10cSrcweir } 845cdf0e10cSrcweir Configuration.removeNode(conf, name); 846cdf0e10cSrcweir 847cdf0e10cSrcweir } 848cdf0e10cSrcweir catch (NoSuchElementException nsex) 849cdf0e10cSrcweir { 850cdf0e10cSrcweir } 851cdf0e10cSrcweir 852cdf0e10cSrcweir settings.cp_DefaultSession.cp_Index = 0; 853cdf0e10cSrcweir node = Configuration.addConfigNode(conf, name); 854cdf0e10cSrcweir settings.cp_DefaultSession.cp_Name = name; 855cdf0e10cSrcweir settings.cp_DefaultSession.writeConfiguration(node, CONFIG_READ_PARAM); 856cdf0e10cSrcweir settings.cp_SavedSessions.reindexSet(conf, name, "Index"); 857cdf0e10cSrcweir Configuration.commit(conf); 858cdf0e10cSrcweir 859cdf0e10cSrcweir // now I reload the sessions to actualize the list/combo boxes load/save sessions. 860cdf0e10cSrcweir settings.cp_SavedSessions.clear(); 861cdf0e10cSrcweir 862cdf0e10cSrcweir Object confView = Configuration.getConfigurationRoot(xMSF, CONFIG_PATH + "/SavedSessions", false); 863cdf0e10cSrcweir settings.cp_SavedSessions.readConfiguration(confView, CONFIG_READ_PARAM); 864cdf0e10cSrcweir 865cdf0e10cSrcweir settings.cp_LastSavedSession = name; 866cdf0e10cSrcweir currentSession = name; 867cdf0e10cSrcweir // now save the name of the last saved session... 868cdf0e10cSrcweir 869cdf0e10cSrcweir settings.cp_LastSavedSession = name; 870cdf0e10cSrcweir 871cdf0e10cSrcweir // TODO add the <none> session... 872cdf0e10cSrcweir prepareSessionLists(); 873cdf0e10cSrcweir ListModelBinder.fillList(lstLoadSettings, settings.cp_SavedSessions.items(), null); 874cdf0e10cSrcweir ListModelBinder.fillComboBox(cbSaveSettings, settings.savedSessions.items(), null); 875cdf0e10cSrcweir selectSession(); 876cdf0e10cSrcweir 877cdf0e10cSrcweir currentSession = settings.cp_LastSavedSession; 878cdf0e10cSrcweir 879cdf0e10cSrcweir return true; 880cdf0e10cSrcweir } 881cdf0e10cSrcweir catch (Exception ex) 882cdf0e10cSrcweir { 883cdf0e10cSrcweir ex.printStackTrace(); 884cdf0e10cSrcweir return false; 885cdf0e10cSrcweir } 886cdf0e10cSrcweir } 887cdf0e10cSrcweir targetStringFor(String publisher)888cdf0e10cSrcweir private String targetStringFor(String publisher) 889cdf0e10cSrcweir { 890cdf0e10cSrcweir CGPublish p = getPublisher(publisher); 891cdf0e10cSrcweir if (p.cp_Publish) 892cdf0e10cSrcweir { 893cdf0e10cSrcweir return "\n" + getFileAccess().getPath(p.cp_URL, null); 894cdf0e10cSrcweir } 895cdf0e10cSrcweir else 896cdf0e10cSrcweir { 897cdf0e10cSrcweir return PropertyNames.EMPTY_STRING; 898cdf0e10cSrcweir } 899cdf0e10cSrcweir } 900cdf0e10cSrcweir 901cdf0e10cSrcweir /** 902cdf0e10cSrcweir * this method will be called when the Status Dialog 903cdf0e10cSrcweir * is hidden. 904cdf0e10cSrcweir * It checks if the "Process" was successfull, and if so, 905cdf0e10cSrcweir * it closes the wizard dialog. 906cdf0e10cSrcweir */ finishWizardFinished()907cdf0e10cSrcweir public void finishWizardFinished() 908cdf0e10cSrcweir { 909cdf0e10cSrcweir if (process.getResult()) 910cdf0e10cSrcweir { 911cdf0e10cSrcweir String targets = 912cdf0e10cSrcweir targetStringFor(LOCAL_PUBLISHER) + 913cdf0e10cSrcweir targetStringFor(ZIP_PUBLISHER) + 914cdf0e10cSrcweir targetStringFor(FTP_PUBLISHER); 915cdf0e10cSrcweir String message = JavaTools.replaceSubString(resources.resFinishedSuccess, targets, "%FILENAME"); 916cdf0e10cSrcweir 917cdf0e10cSrcweir AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(), message, ErrorHandler.ERROR_MESSAGE); 918cdf0e10cSrcweir if (exitOnCreate) 919cdf0e10cSrcweir { 920cdf0e10cSrcweir this.xDialog.endExecute(); 921cdf0e10cSrcweir } 922cdf0e10cSrcweir } 923cdf0e10cSrcweir else 924cdf0e10cSrcweir { 925cdf0e10cSrcweir AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(), resources.resFinishedNoSuccess, ErrorHandler.ERROR_WARNING); 926cdf0e10cSrcweir } 927cdf0e10cSrcweir } 928cdf0e10cSrcweir cancel()929cdf0e10cSrcweir public void cancel() 930cdf0e10cSrcweir { 931cdf0e10cSrcweir xDialog.endExecute(); 932cdf0e10cSrcweir } 933cdf0e10cSrcweir private Process process; 934cdf0e10cSrcweir private boolean exitOnCreate = true; 935cdf0e10cSrcweir 936cdf0e10cSrcweir /** 937cdf0e10cSrcweir * the user clicks the finish/create button. 938cdf0e10cSrcweir */ finishWizard()939cdf0e10cSrcweir public boolean finishWizard() 940cdf0e10cSrcweir { 941cdf0e10cSrcweir finishWizard(true); 942cdf0e10cSrcweir return true; 943cdf0e10cSrcweir } 944cdf0e10cSrcweir 945cdf0e10cSrcweir /** 946cdf0e10cSrcweir * finish the wizard 947cdf0e10cSrcweir * @param exitOnCreate_ should the wizard close after 948cdf0e10cSrcweir * a successfull create. 949cdf0e10cSrcweir * Default is true, 950cdf0e10cSrcweir * I have a hidden feature which enables false here 951cdf0e10cSrcweir */ finishWizard(boolean exitOnCreate_)952cdf0e10cSrcweir public void finishWizard(boolean exitOnCreate_) 953cdf0e10cSrcweir { 954cdf0e10cSrcweir 955cdf0e10cSrcweir exitOnCreate = exitOnCreate_; 956cdf0e10cSrcweir 957cdf0e10cSrcweir /** 958cdf0e10cSrcweir * First I check if ftp password was set, if not - the ftp dialog pops up... 959cdf0e10cSrcweir * This may happen when a session is loaded, since the 960cdf0e10cSrcweir * session saves the ftp url and username, but not the password. 961cdf0e10cSrcweir */ 962cdf0e10cSrcweir final CGPublish p = getPublisher(FTP_PUBLISHER); 963cdf0e10cSrcweir // if ftp is checked, and no proxies are set, and password is empty... 964cdf0e10cSrcweir if (p.cp_Publish && (!proxies) && (p.password == null || p.password.equals(PropertyNames.EMPTY_STRING))) 965cdf0e10cSrcweir { 966cdf0e10cSrcweir if (showFTPDialog(p)) 967cdf0e10cSrcweir { 968cdf0e10cSrcweir updatePublishUI(2); 969cdf0e10cSrcweir //now continue... 970cdf0e10cSrcweir finishWizard2(); 971cdf0e10cSrcweir } 972cdf0e10cSrcweir } 973cdf0e10cSrcweir else 974cdf0e10cSrcweir { 975cdf0e10cSrcweir finishWizard2(); 976cdf0e10cSrcweir } 977cdf0e10cSrcweir } 978cdf0e10cSrcweir 979cdf0e10cSrcweir /** 980cdf0e10cSrcweir * this method is only called 981cdf0e10cSrcweir * if ftp-password was eather set, or 982cdf0e10cSrcweir * the user entered one in the FTP Dialog which 983cdf0e10cSrcweir * popped up when clicking "Create". 984cdf0e10cSrcweir * 985cdf0e10cSrcweir */ finishWizard2()986cdf0e10cSrcweir private void finishWizard2() 987cdf0e10cSrcweir { 988cdf0e10cSrcweir 989cdf0e10cSrcweir CGPublish p = getPublisher(LOCAL_PUBLISHER); 990cdf0e10cSrcweir p.url = p.cp_URL; 991cdf0e10cSrcweir 992cdf0e10cSrcweir /* 993cdf0e10cSrcweir * zip publisher is using another url form... 994cdf0e10cSrcweir */ 995cdf0e10cSrcweir p = getPublisher(ZIP_PUBLISHER); 996cdf0e10cSrcweir //replace the '%' with '%25' 997cdf0e10cSrcweir String url1 = JavaTools.replaceSubString(p.cp_URL, "%25", "%"); 998cdf0e10cSrcweir //replace all '/' with '%2F' 999cdf0e10cSrcweir url1 = JavaTools.replaceSubString(url1, "%2F", "/"); 1000cdf0e10cSrcweir 1001cdf0e10cSrcweir p.url = "vnd.sun.star.zip://" + url1 + "/"; 1002cdf0e10cSrcweir 1003cdf0e10cSrcweir /* 1004cdf0e10cSrcweir * and now ftp... 1005cdf0e10cSrcweir */ 1006cdf0e10cSrcweir p = getPublisher(FTP_PUBLISHER); 1007cdf0e10cSrcweir p.url = FTPDialog.getFullURL(p); 1008cdf0e10cSrcweir 1009cdf0e10cSrcweir 1010cdf0e10cSrcweir /* first we check the publishing targets. If they exist we warn and ask 1011cdf0e10cSrcweir * what to do. a False here means the user said "cancel" (or rather: clicked...) 1012cdf0e10cSrcweir */ 1013cdf0e10cSrcweir if (!publishTargetApproved()) 1014cdf0e10cSrcweir { 1015cdf0e10cSrcweir return; 1016cdf0e10cSrcweir /* 1017cdf0e10cSrcweir * In order to save the session correctly, 1018cdf0e10cSrcweir * I return the value of the ftp publisher cp_Publish 1019cdf0e10cSrcweir * property to its original value... 1020cdf0e10cSrcweir */ 1021cdf0e10cSrcweir } 1022cdf0e10cSrcweir p.cp_Publish = __ftp; 1023cdf0e10cSrcweir 1024cdf0e10cSrcweir //if the "save settings" checkbox is on... 1025cdf0e10cSrcweir if (isSaveSession()) 1026cdf0e10cSrcweir { 1027cdf0e10cSrcweir // if canceled by user 1028cdf0e10cSrcweir if (!saveSession()) 1029cdf0e10cSrcweir { 1030cdf0e10cSrcweir return; 1031cdf0e10cSrcweir } 1032cdf0e10cSrcweir } 1033cdf0e10cSrcweir else 1034cdf0e10cSrcweir { 1035cdf0e10cSrcweir settings.cp_LastSavedSession = PropertyNames.EMPTY_STRING; 1036cdf0e10cSrcweir } 1037cdf0e10cSrcweir try 1038cdf0e10cSrcweir { 1039cdf0e10cSrcweir Object conf = Configuration.getConfigurationRoot(xMSF, CONFIG_PATH, true); 1040cdf0e10cSrcweir Configuration.set( 1041cdf0e10cSrcweir settings.cp_LastSavedSession, 1042cdf0e10cSrcweir "LastSavedSession", conf); 1043cdf0e10cSrcweir Configuration.commit(conf); 1044cdf0e10cSrcweir } 1045cdf0e10cSrcweir catch (Exception ex) 1046cdf0e10cSrcweir { 1047cdf0e10cSrcweir ex.printStackTrace(); 1048cdf0e10cSrcweir } 1049cdf0e10cSrcweir 1050cdf0e10cSrcweir /* 1051cdf0e10cSrcweir * again, if proxies are on, I disable ftp before the creation process 1052cdf0e10cSrcweir * starts. 1053cdf0e10cSrcweir */ 1054cdf0e10cSrcweir if (proxies) 1055cdf0e10cSrcweir { 1056cdf0e10cSrcweir p.cp_Publish = false; 1057cdf0e10cSrcweir 1058cdf0e10cSrcweir /* 1059cdf0e10cSrcweir * There is currently a bug, which crashes office when 1060cdf0e10cSrcweir * writing folders to an existing zip file, after deleting 1061cdf0e10cSrcweir * its content, so I "manually" delete it here... 1062cdf0e10cSrcweir */ 1063cdf0e10cSrcweir } 1064cdf0e10cSrcweir p = getPublisher(ZIP_PUBLISHER); 1065cdf0e10cSrcweir if (getFileAccess().exists(p.cp_URL, false)) 1066cdf0e10cSrcweir { 1067cdf0e10cSrcweir getFileAccess().delete(p.cp_URL); 1068cdf0e10cSrcweir } 1069cdf0e10cSrcweir try 1070cdf0e10cSrcweir { 1071cdf0e10cSrcweir 1072cdf0e10cSrcweir ErrorHandler eh = new ProcessErrorHandler(xMSF, xControl.getPeer(), resources); 1073cdf0e10cSrcweir 1074cdf0e10cSrcweir process = new Process(settings, xMSF, eh); 1075cdf0e10cSrcweir 1076cdf0e10cSrcweir StatusDialog pd = getStatusDialog(); 1077cdf0e10cSrcweir 1078cdf0e10cSrcweir pd.setRenderer(new ProcessStatusRenderer(resources)); 1079cdf0e10cSrcweir pd.execute(this, process.myTask, resources.prodName); //process, 1080cdf0e10cSrcweir process.runProcess(); 1081cdf0e10cSrcweir finishWizardFinished(); 1082cdf0e10cSrcweir process.myTask.removeTaskListener(pd); 1083cdf0e10cSrcweir 1084cdf0e10cSrcweir } 1085cdf0e10cSrcweir catch (Exception ex) 1086cdf0e10cSrcweir { 1087cdf0e10cSrcweir ex.printStackTrace(); 1088cdf0e10cSrcweir } 1089cdf0e10cSrcweir 1090cdf0e10cSrcweir } 1091cdf0e10cSrcweir 1092cdf0e10cSrcweir /** 1093cdf0e10cSrcweir * implements a hidden feature for "finishing" without 1094cdf0e10cSrcweir * closing the wizard. 1095cdf0e10cSrcweir * press "&%" quite fast when the focus is on one 1096cdf0e10cSrcweir * of the last steps' checkboxes. 1097cdf0e10cSrcweir * @author rp143992 1098cdf0e10cSrcweir */ 1099cdf0e10cSrcweir private class Create implements XKeyListener 1100cdf0e10cSrcweir { 1101cdf0e10cSrcweir 1102cdf0e10cSrcweir long time = 0; 1103cdf0e10cSrcweir int count = 0; 1104cdf0e10cSrcweir 1105cdf0e10cSrcweir /* (non-Javadoc) 1106cdf0e10cSrcweir * @see com.sun.star.awt.XKeyListener#keyPressed(com.sun.star.awt.KeyEvent) 1107cdf0e10cSrcweir */ keyPressed(KeyEvent ke)1108cdf0e10cSrcweir public void keyPressed(KeyEvent ke) 1109cdf0e10cSrcweir { 1110cdf0e10cSrcweir if (ke.KeyChar == '&') 1111cdf0e10cSrcweir { 1112cdf0e10cSrcweir time = System.currentTimeMillis(); 1113cdf0e10cSrcweir } 1114cdf0e10cSrcweir else if (ke.KeyChar == '%' && ((System.currentTimeMillis() - time) < 300)) 1115cdf0e10cSrcweir { 1116cdf0e10cSrcweir Boolean b = (Boolean) getControlProperty("btnWizardFinish", PropertyNames.PROPERTY_ENABLED); 1117cdf0e10cSrcweir if (b.booleanValue()) 1118cdf0e10cSrcweir { 1119cdf0e10cSrcweir finishWizard(false); 1120cdf0e10cSrcweir } 1121cdf0e10cSrcweir } 1122cdf0e10cSrcweir } 1123cdf0e10cSrcweir keyReleased(KeyEvent arg0)1124cdf0e10cSrcweir public void keyReleased(KeyEvent arg0) 1125cdf0e10cSrcweir { 1126cdf0e10cSrcweir } 1127cdf0e10cSrcweir disposing(EventObject arg0)1128cdf0e10cSrcweir public void disposing(EventObject arg0) 1129cdf0e10cSrcweir { 1130cdf0e10cSrcweir } 1131cdf0e10cSrcweir } 1132cdf0e10cSrcweir 1133cdf0e10cSrcweir /** 1134cdf0e10cSrcweir * is called on the WindowHidden event, 1135cdf0e10cSrcweir * deletes the temporary directory. 1136cdf0e10cSrcweir */ cleanup()1137cdf0e10cSrcweir public void cleanup() 1138cdf0e10cSrcweir { 1139cdf0e10cSrcweir 1140cdf0e10cSrcweir 1141cdf0e10cSrcweir try 1142cdf0e10cSrcweir { 1143cdf0e10cSrcweir dpStylePreview.dispose(); 1144cdf0e10cSrcweir } 1145cdf0e10cSrcweir catch (Exception ex) 1146cdf0e10cSrcweir { 1147cdf0e10cSrcweir ex.printStackTrace(); 1148cdf0e10cSrcweir } 1149cdf0e10cSrcweir 1150cdf0e10cSrcweir stylePreview.cleanup(); 1151cdf0e10cSrcweir 1152cdf0e10cSrcweir try 1153cdf0e10cSrcweir { 1154cdf0e10cSrcweir if (bgDialog != null) 1155cdf0e10cSrcweir { 1156cdf0e10cSrcweir bgDialog.xComponent.dispose(); 1157cdf0e10cSrcweir } 1158cdf0e10cSrcweir } 1159cdf0e10cSrcweir catch (Exception ex) 1160cdf0e10cSrcweir { 1161cdf0e10cSrcweir ex.printStackTrace(); 1162cdf0e10cSrcweir } 1163cdf0e10cSrcweir 1164cdf0e10cSrcweir try 1165cdf0e10cSrcweir { 1166cdf0e10cSrcweir if (iconsDialog != null) 1167cdf0e10cSrcweir { 1168cdf0e10cSrcweir iconsDialog.xComponent.dispose(); 1169cdf0e10cSrcweir } 1170cdf0e10cSrcweir } 1171cdf0e10cSrcweir catch (Exception ex) 1172cdf0e10cSrcweir { 1173cdf0e10cSrcweir ex.printStackTrace(); 1174cdf0e10cSrcweir } 1175cdf0e10cSrcweir 1176cdf0e10cSrcweir try 1177cdf0e10cSrcweir { 1178cdf0e10cSrcweir if (ftpDialog != null) 1179cdf0e10cSrcweir { 1180cdf0e10cSrcweir ftpDialog.xComponent.dispose(); 1181cdf0e10cSrcweir } 1182cdf0e10cSrcweir } 1183cdf0e10cSrcweir catch (Exception ex) 1184cdf0e10cSrcweir { 1185cdf0e10cSrcweir ex.printStackTrace(); 1186cdf0e10cSrcweir } 1187cdf0e10cSrcweir 1188cdf0e10cSrcweir try 1189cdf0e10cSrcweir { 1190cdf0e10cSrcweir xComponent.dispose(); 1191cdf0e10cSrcweir } 1192cdf0e10cSrcweir catch (Exception ex) 1193cdf0e10cSrcweir { 1194cdf0e10cSrcweir ex.printStackTrace(); 1195cdf0e10cSrcweir } 1196cdf0e10cSrcweir 1197cdf0e10cSrcweir try 1198cdf0e10cSrcweir { 1199cdf0e10cSrcweir //XCloseable xCloseable = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, myDocument); 1200cdf0e10cSrcweir //if (xCloseable != null) 1201cdf0e10cSrcweir // xCloseable.close(false); 1202cdf0e10cSrcweir 1203cdf0e10cSrcweir XCloseable xCloseable = UnoRuntime.queryInterface(XCloseable.class, myFrame); 1204cdf0e10cSrcweir if (xCloseable != null) 1205cdf0e10cSrcweir { 1206cdf0e10cSrcweir xCloseable.close(false); 1207cdf0e10cSrcweir } 1208cdf0e10cSrcweir } 1209cdf0e10cSrcweir catch (Exception ex) 1210cdf0e10cSrcweir { 1211cdf0e10cSrcweir ex.printStackTrace(); 1212cdf0e10cSrcweir } 1213cdf0e10cSrcweir 1214cdf0e10cSrcweir } 1215cdf0e10cSrcweir 1216cdf0e10cSrcweir public class LoadDocs 1217cdf0e10cSrcweir { 1218cdf0e10cSrcweir 1219cdf0e10cSrcweir private XControl xC; 1220cdf0e10cSrcweir String[] files; 1221cdf0e10cSrcweir Task task; 1222cdf0e10cSrcweir LoadDocs(XControl xC_, String[] files_, Task task_)1223cdf0e10cSrcweir public LoadDocs(XControl xC_, String[] files_, Task task_) 1224cdf0e10cSrcweir { 1225cdf0e10cSrcweir xC = xC_; 1226cdf0e10cSrcweir files = files_; 1227cdf0e10cSrcweir task = task_; 1228cdf0e10cSrcweir } 1229cdf0e10cSrcweir loadDocuments()1230cdf0e10cSrcweir public void loadDocuments() 1231cdf0e10cSrcweir { 1232cdf0e10cSrcweir //LogTaskListener lts = new LogTaskListener(); 1233cdf0e10cSrcweir //task.addTaskListener(lts); 1234cdf0e10cSrcweir 1235cdf0e10cSrcweir // task.start(); 1236cdf0e10cSrcweir 1237cdf0e10cSrcweir // where the documents are added to in the list (offset) 1238cdf0e10cSrcweir int offset = (getSelectedDoc().length > 0 ? selectedDoc[0] + 1 : getDocsCount()); 1239cdf0e10cSrcweir 1240cdf0e10cSrcweir /* if the user chose one file, the list starts at 0, 1241cdf0e10cSrcweir * if he chose more than one, the first entry is a directory name, 1242cdf0e10cSrcweir * all the others are filenames. 1243cdf0e10cSrcweir */ 1244cdf0e10cSrcweir int start = (files.length > 1 ? 1 : 0); 1245cdf0e10cSrcweir /* 1246cdf0e10cSrcweir * Number of documents failed to validate. 1247cdf0e10cSrcweir */ 1248cdf0e10cSrcweir int failed = 0; 1249cdf0e10cSrcweir 1250cdf0e10cSrcweir // store the directory 1251cdf0e10cSrcweir settings.cp_DefaultSession.cp_InDirectory = start == 1 ? files[0] : FileAccess.getParentDir(files[0]); 1252cdf0e10cSrcweir 1253cdf0e10cSrcweir /* 1254cdf0e10cSrcweir * Here i go through each file, and validate it. 1255cdf0e10cSrcweir * If its ok, I add it to the ListModel/ConfigSet 1256cdf0e10cSrcweir */ 1257cdf0e10cSrcweir for (int i = start; i < files.length; i++) 1258cdf0e10cSrcweir { 1259cdf0e10cSrcweir CGDocument doc = new CGDocument(); 1260cdf0e10cSrcweir doc.setRoot(settings); 1261cdf0e10cSrcweir 1262cdf0e10cSrcweir doc.cp_URL = (start == 0) ? files[i] : FileAccess.connectURLs(files[0], files[i]); 1263cdf0e10cSrcweir 1264cdf0e10cSrcweir /* so - i check each document and if it is ok I add it. 1265cdf0e10cSrcweir * The failed variable is used only to calculate the place to add - 1266cdf0e10cSrcweir * Error reporting to the user is (or should (-: )done in the checkDocument(...) method 1267cdf0e10cSrcweir */ 1268cdf0e10cSrcweir if (checkDocument(doc, task, xC)) 1269cdf0e10cSrcweir { 1270cdf0e10cSrcweir settings.cp_DefaultSession.cp_Content.cp_Documents.add(offset + i - failed - start, doc); 1271cdf0e10cSrcweir } 1272cdf0e10cSrcweir else 1273cdf0e10cSrcweir { 1274cdf0e10cSrcweir failed++; 1275cdf0e10cSrcweir } 1276cdf0e10cSrcweir } 1277cdf0e10cSrcweir 1278cdf0e10cSrcweir // if any documents where added, 1279cdf0e10cSrcweir // set the first one to be the current-selected document. 1280cdf0e10cSrcweir if (files.length > start + failed) 1281cdf0e10cSrcweir { 1282cdf0e10cSrcweir setSelectedDoc(new short[] 1283cdf0e10cSrcweir { 1284cdf0e10cSrcweir (short) offset 1285cdf0e10cSrcweir }); 1286cdf0e10cSrcweir } 1287cdf0e10cSrcweir // update the ui... 1288cdf0e10cSrcweir docListDA.updateUI(); 1289cdf0e10cSrcweir // this enables/disables the next steps. 1290cdf0e10cSrcweir // when no documents in the list, all next steps are disabled 1291cdf0e10cSrcweir checkSteps(); 1292cdf0e10cSrcweir /* a small insurance that the status dialog will 1293cdf0e10cSrcweir * really close... 1294cdf0e10cSrcweir */ 1295cdf0e10cSrcweir while (task.getStatus() < task.getMax()) 1296cdf0e10cSrcweir { 1297cdf0e10cSrcweir task.advance(false); 1298cdf0e10cSrcweir } 1299cdf0e10cSrcweir } 1300cdf0e10cSrcweir } 1301cdf0e10cSrcweir } 1302cdf0e10cSrcweir 1303