1 /*
2 
3  * HomeView.java 28 oct 2008
4  *
5  * Sweet Home 3D, Copyright (c) 2008 Emmanuel PUYBARET / eTeks <info@eteks.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21 package com.eteks.sweethome3d.viewcontroller;
22 
23 import java.util.List;
24 import java.util.concurrent.Callable;
25 
26 import com.eteks.sweethome3d.model.Camera;
27 import com.eteks.sweethome3d.model.Content;
28 import com.eteks.sweethome3d.model.Home;
29 import com.eteks.sweethome3d.model.InterruptedRecorderException;
30 import com.eteks.sweethome3d.model.RecorderException;
31 import com.eteks.sweethome3d.model.Selectable;
32 
33 /**
34  * The main view that displays a home.
35  * @author Emmanuel Puybaret
36  */
37 public interface HomeView extends View {
38   /**
39    * The actions proposed by the view to user.
40    */
41   public enum ActionType {
42       NEW_HOME, NEW_HOME_FROM_EXAMPLE, CLOSE, OPEN, DELETE_RECENT_HOMES, SAVE, SAVE_AS, SAVE_AND_COMPRESS,
43       PAGE_SETUP, PRINT_PREVIEW, PRINT, PRINT_TO_PDF, PREFERENCES, EXIT,
44       UNDO, REDO, CUT, COPY, PASTE, PASTE_TO_GROUP, PASTE_STYLE, DELETE, SELECT_ALL, SELECT_ALL_AT_ALL_LEVELS,
45       ADD_HOME_FURNITURE, ADD_FURNITURE_TO_GROUP, DELETE_HOME_FURNITURE, MODIFY_FURNITURE,
46       IMPORT_FURNITURE, IMPORT_FURNITURE_LIBRARY, IMPORT_TEXTURE, IMPORT_TEXTURES_LIBRARY,
47       SORT_HOME_FURNITURE_BY_CATALOG_ID, SORT_HOME_FURNITURE_BY_NAME, SORT_HOME_FURNITURE_BY_CREATOR,
48       SORT_HOME_FURNITURE_BY_WIDTH, SORT_HOME_FURNITURE_BY_DEPTH, SORT_HOME_FURNITURE_BY_HEIGHT,
49       SORT_HOME_FURNITURE_BY_X, SORT_HOME_FURNITURE_BY_Y, SORT_HOME_FURNITURE_BY_ELEVATION,
50       SORT_HOME_FURNITURE_BY_ANGLE, SORT_HOME_FURNITURE_BY_LEVEL, SORT_HOME_FURNITURE_BY_MODEL_SIZE,
51       SORT_HOME_FURNITURE_BY_COLOR, SORT_HOME_FURNITURE_BY_TEXTURE,
52       SORT_HOME_FURNITURE_BY_MOVABILITY, SORT_HOME_FURNITURE_BY_TYPE, SORT_HOME_FURNITURE_BY_VISIBILITY,
53       SORT_HOME_FURNITURE_BY_PRICE, SORT_HOME_FURNITURE_BY_VALUE_ADDED_TAX_PERCENTAGE,
54       SORT_HOME_FURNITURE_BY_VALUE_ADDED_TAX, SORT_HOME_FURNITURE_BY_PRICE_VALUE_ADDED_TAX_INCLUDED,
55       SORT_HOME_FURNITURE_BY_DESCENDING_ORDER,
56       DISPLAY_HOME_FURNITURE_CATALOG_ID, DISPLAY_HOME_FURNITURE_NAME, DISPLAY_HOME_FURNITURE_CREATOR,
57       DISPLAY_HOME_FURNITURE_WIDTH, DISPLAY_HOME_FURNITURE_DEPTH, DISPLAY_HOME_FURNITURE_HEIGHT,
58       DISPLAY_HOME_FURNITURE_X, DISPLAY_HOME_FURNITURE_Y, DISPLAY_HOME_FURNITURE_ELEVATION,
59       DISPLAY_HOME_FURNITURE_ANGLE, DISPLAY_HOME_FURNITURE_LEVEL, DISPLAY_HOME_FURNITURE_MODEL_SIZE,
60       DISPLAY_HOME_FURNITURE_COLOR, DISPLAY_HOME_FURNITURE_TEXTURE,
61       DISPLAY_HOME_FURNITURE_MOVABLE, DISPLAY_HOME_FURNITURE_DOOR_OR_WINDOW, DISPLAY_HOME_FURNITURE_VISIBLE,
62       DISPLAY_HOME_FURNITURE_PRICE, DISPLAY_HOME_FURNITURE_VALUE_ADDED_TAX_PERCENTAGE,
63       DISPLAY_HOME_FURNITURE_VALUE_ADDED_TAX, DISPLAY_HOME_FURNITURE_PRICE_VALUE_ADDED_TAX_INCLUDED,
64       ALIGN_FURNITURE_ON_TOP, ALIGN_FURNITURE_ON_BOTTOM, ALIGN_FURNITURE_ON_LEFT, ALIGN_FURNITURE_ON_RIGHT,
65       ALIGN_FURNITURE_ON_FRONT_SIDE, ALIGN_FURNITURE_ON_BACK_SIDE, ALIGN_FURNITURE_ON_LEFT_SIDE, ALIGN_FURNITURE_ON_RIGHT_SIDE, ALIGN_FURNITURE_SIDE_BY_SIDE,
66       DISTRIBUTE_FURNITURE_HORIZONTALLY, DISTRIBUTE_FURNITURE_VERTICALLY, RESET_FURNITURE_ELEVATION,
67       GROUP_FURNITURE, UNGROUP_FURNITURE, EXPORT_TO_CSV,
68       SELECT, PAN, CREATE_WALLS, CREATE_ROOMS, CREATE_DIMENSION_LINES, CREATE_POLYLINES, CREATE_LABELS, DELETE_SELECTION,
69       LOCK_BASE_PLAN, UNLOCK_BASE_PLAN, ENABLE_MAGNETISM, DISABLE_MAGNETISM, FLIP_HORIZONTALLY, FLIP_VERTICALLY,
70       MODIFY_COMPASS, MODIFY_WALL, JOIN_WALLS, REVERSE_WALL_DIRECTION, SPLIT_WALL,
71       MODIFY_ROOM, ADD_ROOM_POINT, DELETE_ROOM_POINT, MODIFY_POLYLINE, MODIFY_LABEL,
72       INCREASE_TEXT_SIZE, DECREASE_TEXT_SIZE, TOGGLE_BOLD_STYLE, TOGGLE_ITALIC_STYLE,
73       IMPORT_BACKGROUND_IMAGE, MODIFY_BACKGROUND_IMAGE, HIDE_BACKGROUND_IMAGE, SHOW_BACKGROUND_IMAGE, DELETE_BACKGROUND_IMAGE,
74       ADD_LEVEL, ADD_LEVEL_AT_SAME_ELEVATION, MAKE_LEVEL_VIEWABLE, MAKE_LEVEL_UNVIEWABLE,
75       MAKE_LEVEL_ONLY_VIEWABLE_ONE, MAKE_ALL_LEVELS_VIEWABLE, MODIFY_LEVEL, DELETE_LEVEL,
76       ZOOM_OUT, ZOOM_IN, EXPORT_TO_SVG,
77       SELECT_OBJECT, TOGGLE_SELECTION, VIEW_FROM_TOP, VIEW_FROM_OBSERVER, MODIFY_OBSERVER, STORE_POINT_OF_VIEW, DELETE_POINTS_OF_VIEW, CREATE_PHOTOS_AT_POINTS_OF_VIEW, DETACH_3D_VIEW, ATTACH_3D_VIEW,
78       DISPLAY_ALL_LEVELS, DISPLAY_SELECTED_LEVEL, MODIFY_3D_ATTRIBUTES, CREATE_PHOTO, CREATE_VIDEO, EXPORT_TO_OBJ,
79       HELP, ABOUT}
80   public enum SaveAnswer {SAVE, CANCEL, DO_NOT_SAVE}
81   public enum OpenDamagedHomeAnswer {REMOVE_DAMAGED_ITEMS, REPLACE_DAMAGED_ITEMS, DO_NOT_OPEN_HOME}
82 
83   /**
84    * Enables or disables the action matching <code>actionType</code>.
85    */
setEnabled(ActionType actionType, boolean enabled)86   public abstract void setEnabled(ActionType actionType,
87                                   boolean enabled);
88 
89   /**
90    * Sets the name and tool tip of undo and redo actions. If a parameter is <code>null</code>,
91    * the properties will be reset to their initial values.
92    */
setUndoRedoName(String undoText, String redoText)93   public abstract void setUndoRedoName(String undoText,
94                                        String redoText);
95 
96   /**
97    * Enables or disables transfer between components.
98    */
setTransferEnabled(boolean enabled)99   public abstract void setTransferEnabled(boolean enabled);
100 
101 
102   /**
103    * Detaches the given <code>view</code> from home view.
104    */
detachView(View view)105   public abstract void detachView(View view);
106 
107   /**
108    * Attaches the given <code>view</code> to home view.
109    */
attachView(View view)110   public abstract void attachView(View view);
111 
112   /**
113    * Displays a content chooser open dialog to choose the name of a home.
114    */
showOpenDialog()115   public abstract String showOpenDialog();
116 
117   /**
118    * Displays a dialog that lets user choose what he wants
119    * to do with a damaged home he tries to open it.
120    * @since 4.4
121    */
confirmOpenDamagedHome(String homeName, Home damagedHome, List<Content> invalidContent)122   public abstract OpenDamagedHomeAnswer confirmOpenDamagedHome(String homeName,
123                                                                Home damagedHome,
124                                                                List<Content> invalidContent);
125 
126   /**
127    * Displays a dialog to let the user choose a home example.
128    * @since 5.5
129    */
showNewHomeFromExampleDialog()130   public abstract String showNewHomeFromExampleDialog();
131 
132   /**
133    * Displays a content chooser open dialog to choose a language library.
134    */
showImportLanguageLibraryDialog()135   public abstract String showImportLanguageLibraryDialog();
136 
137   /**
138    * Displays a dialog that lets user choose whether he wants to overwrite
139    * an existing language library or not.
140    */
confirmReplaceLanguageLibrary(String languageLibraryName)141   public abstract boolean confirmReplaceLanguageLibrary(String languageLibraryName);
142 
143   /**
144    * Displays a content chooser open dialog to choose a furniture library.
145    */
showImportFurnitureLibraryDialog()146   public abstract String showImportFurnitureLibraryDialog();
147 
148   /**
149    * Displays a dialog that lets user choose whether he wants to overwrite
150    * an existing furniture library or not.
151    */
confirmReplaceFurnitureLibrary(String furnitureLibraryName)152   public abstract boolean confirmReplaceFurnitureLibrary(String furnitureLibraryName);
153 
154   /**
155    * Displays a content chooser open dialog to choose a textures library.
156    */
showImportTexturesLibraryDialog()157   public abstract String showImportTexturesLibraryDialog();
158 
159   /**
160    * Displays a dialog that lets user choose whether he wants to overwrite
161    * an existing textures library or not.
162    */
confirmReplaceTexturesLibrary(String texturesLibraryName)163   public abstract boolean confirmReplaceTexturesLibrary(String texturesLibraryName);
164 
165   /**
166    * Displays a dialog that lets user choose whether he wants to overwrite
167    * an existing plug-in or not.
168    */
confirmReplacePlugin(String pluginName)169   public abstract boolean confirmReplacePlugin(String pluginName);
170 
171   /**
172    * Displays a content chooser save dialog to choose the name of a home.
173    */
showSaveDialog(String homeName)174   public abstract String showSaveDialog(String homeName);
175 
176   /**
177    * Displays a dialog that lets user choose whether he wants to save
178    * the current home or not.
179    * @return {@link SaveAnswer#SAVE} if user chose to save home,
180    * {@link SaveAnswer#DO_NOT_SAVE} if user don't want to save home,
181    * or {@link SaveAnswer#CANCEL} if doesn't want to continue current operation.
182    */
confirmSave(String homeName)183   public abstract SaveAnswer confirmSave(String homeName);
184 
185   /**
186    * Displays a dialog that let user choose whether he wants to save
187    * a home that was created with a newer version of Sweet Home 3D.
188    * @return <code>true</code> if user confirmed to save.
189    */
confirmSaveNewerHome(String homeName)190   public abstract boolean confirmSaveNewerHome(String homeName);
191 
192   /**
193    * Displays a dialog that let user choose whether he wants to delete
194    * the selected furniture from catalog or not.
195    * @return <code>true</code> if user confirmed to delete.
196    */
confirmDeleteCatalogSelection()197   public abstract boolean confirmDeleteCatalogSelection();
198 
199   /**
200    * Displays a dialog that let user choose whether he wants to exit
201    * application or not.
202    * @return <code>true</code> if user confirmed to exit.
203    */
confirmExit()204   public abstract boolean confirmExit();
205 
206   /**
207    * Displays <code>message</code> in an error message box.
208    */
showError(String message)209   public abstract void showError(String message);
210 
211   /**
212    * Displays <code>message</code> in a message box.
213    */
showMessage(String message)214   public abstract void showMessage(String message);
215 
216   /**
217    * Displays the tip matching <code>actionTipKey</code> and
218    * returns <code>true</code> if the user chose not to display again the tip.
219    */
showActionTipMessage(String actionTipKey)220   public abstract boolean showActionTipMessage(String actionTipKey);
221 
222   /**
223    * Displays an about dialog.
224    */
showAboutDialog()225   public abstract void showAboutDialog();
226 
227   /**
228    * Shows a print dialog to print the home displayed by this pane.
229    * @return a print task to execute or <code>null</code> if the user canceled print.
230    *    The <code>call</code> method of the returned task may throw a
231    *    {@link RecorderException RecorderException} exception if print failed
232    *    or an {@link InterruptedRecorderException InterruptedRecorderException}
233    *    exception if it was interrupted.
234    */
showPrintDialog()235   public abstract Callable<Void> showPrintDialog();
236 
237   /**
238    * Shows a content chooser save dialog to print a home in a PDF file.
239    */
showPrintToPDFDialog(String homeName)240   public abstract String showPrintToPDFDialog(String homeName);
241 
242   /**
243    * Prints a home to a given PDF file. This method may be overridden
244    * to write to another kind of output stream.
245    * Caution !!! This method may be called from a threaded task.
246    */
printToPDF(String pdfFile)247   public abstract void printToPDF(String pdfFile) throws RecorderException;
248 
249   /**
250    * Shows a content chooser save dialog to export furniture list in a CSV file.
251    */
showExportToCSVDialog(String name)252   public abstract String showExportToCSVDialog(String name);
253 
254   /**
255    * Exports furniture list to a given SVG file.
256    * Caution !!! This method may be called from a threaded task.
257    */
exportToCSV(String csvName)258   public abstract void exportToCSV(String csvName) throws RecorderException;
259 
260   /**
261    * Shows a content chooser save dialog to export a home plan in a SVG file.
262    */
showExportToSVGDialog(String name)263   public abstract String showExportToSVGDialog(String name);
264 
265   /**
266    * Exports the plan objects to a given SVG file.
267    * Caution !!! This method may be called from a threaded task.
268    */
exportToSVG(String svgName)269   public abstract void exportToSVG(String svgName) throws RecorderException;
270 
271   /**
272    * Shows a content chooser save dialog to export a 3D home in a OBJ file.
273    */
showExportToOBJDialog(String homeName)274   public abstract String showExportToOBJDialog(String homeName);
275 
276   /**
277    * Exports the 3D home objects to a given OBJ file.
278    * Caution !!! This method may be called from a threaded task.
279    */
exportToOBJ(String objFile)280   public abstract void exportToOBJ(String objFile) throws RecorderException;
281 
282   /**
283    * Displays a dialog that lets the user choose a name for the current camera.
284    */
showStoreCameraDialog(String cameraName)285   public abstract String showStoreCameraDialog(String cameraName);
286 
287   /**
288    * Displays a dialog showing the list of cameras stored in home
289    * and returns the ones selected by the user to be deleted.
290    */
showDeletedCamerasDialog()291   public abstract List<Camera> showDeletedCamerasDialog();
292 
293    /**
294    * Returns <code>true</code> if clipboard contains data that
295    * components are able to handle.
296    */
isClipboardEmpty()297   public abstract boolean isClipboardEmpty();
298 
299   /**
300    * Returns the list of selectable items that are currently in clipboard
301    * or <code>null</code> if clipboard doesn't contain any selectable item.
302    * @since 5.0
303    */
getClipboardItems()304   public abstract List<Selectable> getClipboardItems();
305 
306   /**
307    * Displays the given message and returns <code>false</code> if the user
308    * doesn't want to be informed of the displayed updates and <code>showOnlyMessage</code> is <code>false</code>.
309    */
showUpdatesMessage(String updatesMessage, boolean showOnlyMessage)310   public abstract boolean showUpdatesMessage(String updatesMessage, boolean showOnlyMessage);
311 
312   /**
313    * Execute <code>runnable</code> asynchronously in the thread
314    * that manages toolkit events.
315    */
invokeLater(Runnable runnable)316   public abstract void invokeLater(Runnable runnable);
317 }