001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: /*
043: * File : IDEManagerAdapter.java
044: * Version : 1.0
045: * Description : Stub implementation of the IDE manager interface, suitable
046: * for subclassing by IDE integrations.
047: * Author : Darshan
048: */
049: package org.netbeans.modules.uml.integration.ide;
050:
051: import java.awt.Frame;
052: import java.io.File;
053: import java.util.ArrayList;
054:
055: import javax.swing.JFileChooser;
056: import javax.swing.SwingUtilities;
057: import javax.swing.filechooser.FileFilter;
058:
059: import org.netbeans.modules.uml.integration.ide.dialogs.IProgressIndicator;
060: import org.netbeans.modules.uml.integration.ide.dialogs.ProgressIndicator;
061: import org.netbeans.modules.uml.core.metamodel.diagrams.IDiagram;
062: import org.netbeans.modules.uml.core.metamodel.structure.IProject;
063:
064: /**
065: * Stub implementation of the IDE manager interface, suitable for subclassing
066: * by IDE integrations. If the integration doesn't subclass this, an instance
067: * of this will be used as the IDE manager.
068: *
069: * @author Darshan
070: * @version 1.0
071: */
072: public class IDEManagerAdapter implements IIDEManager {
073: public boolean isPropertyEditorVisible() {
074: return true;
075: }
076:
077: public void setPropertyEditorVisible(boolean vis) {
078: }
079:
080: public void saveCurrentProject() {
081: }
082:
083: public boolean isProjectDirty() {
084: return false;
085: }
086:
087: public void setProjectDirty(boolean dirty) {
088: }
089:
090: public String getProjectToInsert() {
091: JFileChooser fc = new JFileChooser();
092: fc.setDialogTitle(UMLSupport
093: .getString("Dialog.InsertProject.Title"));
094:
095: fc.setFileFilter(new FileFilter() {
096: public String getDescription() {
097: return UMLSupport
098: .getString("Dialog.InsertProject.FileFilter.Description");
099: }
100:
101: public boolean accept(File f) {
102: return f
103: .toString()
104: .endsWith(
105: UMLSupport
106: .getString("Dialog.InsertProject.ProjectExtension"))
107: || f.isDirectory();
108: }
109: });
110: int retVal = fc.showOpenDialog(null);
111: if (retVal == JFileChooser.APPROVE_OPTION) {
112: File selectedFile = fc.getSelectedFile();
113: return selectedFile.toString();
114: }
115: return null;
116: }
117:
118: /**
119: * Returns the top window Frame of the IDE. AWT-based IDEs should override
120: * this method to return the main IDE window; other IDEs can return
121: * <code>null</code> and override getProgressIndicator() instead.
122: *
123: * @see IIDEManager#getTopFrame()
124: * @return <code>null</code> always.
125: */
126: public Frame getTopFrame() {
127: return null;
128: }
129:
130: /**
131: * Returns an <code>IProgressIndicator</code> instance
132: * (<code>JDialog</code> implementation), modal to the <code>Frame</code>
133: * returned by <code>getTopFrame()</code> if non-null, or a free-floating
134: * modal dialog if <code>getTopFrame()</code> returns <code>null</code>.
135: *
136: * @return An <code>IProgressIndicator</code>
137: */
138: public IProgressIndicator getProgressIndicator() {
139: Frame topFrame = getTopFrame();
140: ProgressIndicator pi = null;
141: if (topFrame != null)
142: pi = new ProgressIndicator(topFrame, UMLSupport
143: .getString("Dialog.RoundtripProgress.Title"));
144: else
145: pi = new ProgressIndicator(UMLSupport
146: .getString("Dialog.RoundtripProgress.Title"));
147: pi.setModal(true);
148: return pi;
149: }
150:
151: /**
152: * Returns the diagram kind of the given diagram.
153: * @param diagram An IDiagram, which may be null.
154: * @return The diagram kind, one of the constants in DiagramKind.
155: */
156: public int getDiagramKind(IDiagram diagram) {
157: if (diagram == null)
158: return DiagramKind.DK_DIAGRAM;
159: return diagram.getDiagramKind();
160: }
161:
162: public void synchronizeFiles(ArrayList files) {
163: }
164:
165: public void reviveDescribeObjects() {
166: }
167:
168: public void invokeLater(Runnable r) {
169: SwingUtilities.invokeLater(r);
170: }
171:
172: public void renameProject(String oldName, String newName) {
173: // Do nothing.
174: }
175:
176: public void openProject(IProject describeProject, String project) {
177: }
178:
179: /* (non-Javadoc)
180: * @see com.embarcadero.integration.IIDEManager#closeProject(com.embarcadero.describe.structure.IProject)
181: */
182: public void closeProject(IProject proj) {
183: UMLSupport.getUMLSupport().closeProject(proj);
184: }
185:
186: /* (non-Javadoc)
187: * @see com.embarcadero.integration.IIDEManager#activateIDEProject(com.embarcadero.describe.structure.IProject)
188: */
189: public boolean activateIDEProject(IProject describeProject) {
190: return true;
191: }
192:
193: public void loadPreferences() {
194: Preferences.readPreferences();
195: }
196:
197: public String getDefaultWorkspaceDirectory() {
198: return null;
199: }
200:
201: public void handleRemoveDescribeProject(IProject proj) {
202: }
203:
204: /* (non-Javadoc)
205: * @see com.embarcadero.integration.IIDEManager#deleteFile(java.io.File)
206: */
207: public void deleteFile(File file) {
208: // IDEs will certainly want to override this default behavior.
209: file.delete();
210: }
211:
212: public void confirmDeleteSourceFile(File file) {
213: // IDEs will certainly want to override this default behavior.
214: }
215:
216: public int getIDEType() {
217: return UMLSupport.SU_IDE_NONE;
218: }
219:
220: }
|