public void setFocusManager(final FocusManager focusManager) { if (focusManager == null) { throw new NakedObjectException("No focus manager set up"); } this.focusManager = focusManager; } }
public void unindent() { if (indent == 0) { throw new NakedObjectException(); } indent--; } }
public void ensureEmpty() { if (changes.size() > 0) { throw new NakedObjectException("Update notifier still has updates"); } }
public void open(final Location location, final String name, final String description, final String help) { final String exec = program + " " + help; try { Runtime.getRuntime().exec(exec); LOG.debug("executing '" + exec + "'"); } catch (final IOException e) { throw new NakedObjectException("faile to execute '" + exec + "'", e); } }
private String findExistingId(final Map<String,?> map, final Object object) { for(String id: map.keySet()) { if (object.equals(map.get(id))) { return id; } } throw new NakedObjectException(); }
public synchronized void returnWorker(final Worker worker) { if (available.contains(worker)) { throw new NakedObjectException("Worker thread has already been returned to queue"); } LOG.debug("worker thread returned " + worker); available.addElement(worker); notify(); }
public synchronized void returnWorker(final Worker worker) { if (available.contains(worker)) { throw new NakedObjectException("Worker thread has already been returned to queue"); } LOG.debug("worker thread returned " + worker); available.addElement(worker); notify(); }
public static void saveToFile(final File file, final String title, final String text) { try { final PrintWriter writer = new PrintWriter(new FileWriter(file)); writer.println(title); writer.println(); writer.println(text.toString()); writer.close(); } catch (final IOException e) { throw new NakedObjectException(e); } }
private ServerSocket newServerSocket(final int port) { try { ServerSocket socket = new ServerSocket(port); LOG.info("nof listener started on " + socket); socket.setSoTimeout(1000); return socket; } catch (final IOException e) { throw new NakedObjectException(e); } finally { shutdown(socket); } }
public void setImageDirectory(final String imageDirectory) { this.imageDirectory = new File(imageDirectory); if (!this.imageDirectory.exists()) { throw new NakedObjectException("No image directory found: " + imageDirectory); } unknownImageFile = imageFile(UNKNOWN_IMAGE); }
public Perspective getPerspective(String name) { PerspectiveEntry perspectiveEntry = userProfile.getPerspective(name); if (perspectiveEntry == null) { throw new NakedObjectException("No perspective found for " + name); } return new PerspectiveImpl(perspectiveEntry); }
public static Color getColor(final String name) { final Color color = getInstance().colorsAndFonts.getColor(name); if (color == null) { throw new NakedObjectException("No such color: " + name); } return color; }
public static Text getText(final String name) { final Text text = getInstance().colorsAndFonts.getText(name); if (text == null) { throw new NakedObjectException("No such text style: " + name); } return text; }
private View createFieldView(final View view, final ParameterContent parameter, int sequence) { final View fieldView = subviewDesign.createSubview(parameter, view.getViewAxis(), sequence); if (fieldView == null) { throw new NakedObjectException("All parameters must be shown"); } return fieldView; }
private NakedObjectMember getAssociationElseThrowException(final Identifier id, final NakedObjectSpecification specification) { NakedObjectMember member = specification.getAssociation(id.getMemberName()); if (member == null) { throw new NakedObjectException("No property or collection found for id " + id); } return member; }
private List<Class<?>> newlyDiscoveredClasses() { List<Class<?>> newlyDiscoveredClasses = new ArrayList<Class<?>>(); NakedObjectSpecification[] noSpecs = allSpecifications(); try { for(NakedObjectSpecification noSpec: noSpecs) { getSpecificationTraverser().traverseReferencedClasses(noSpec, newlyDiscoveredClasses); } } catch (ClassNotFoundException ex) { throw new NakedObjectException(ex); } return newlyDiscoveredClasses; }
private NakedObjectMember getActionElseThrowException(final Identifier id, final NakedObjectSpecification specification) { NakedObjectMember member = specification.getObjectAction( NakedObjectActionConstants.USER, id.getMemberName(), getMemberParameterSpecifications(id)); if (member == null) { throw new NakedObjectException("No user action found for id " + id); } return member; }
private NakedObject restoreLeafObject(final String encodedObject, final NakedObjectSpecification specification) { final EncodableFacet encoder = specification.getFacet(EncodableFacet.class); if (encoder == null) { throw new NakedObjectException("No encoder for " + specification.getFullName()); } final NakedObject object = encoder.fromEncodedString(encodedObject); return object; }
public void deleteLeft(final CursorPosition cursorAt) { final BlockToLineMapping mapping = findBlockFor(cursorAt.getLine()); if (mapping == null || mapping.textBlock == null) { throw new NakedObjectException("invalid block " + mapping + " for line " + cursorAt.getLine()); } mapping.textBlock.deleteLeft(mapping.line, cursorAt.getCharacter()); }
private NakedObject findService() { final List<NakedObject> services = getRuntimeContext().getServices(); for (NakedObject serviceAdapter : services) { if (serviceAdapter.getSpecification() == getOnType()) { return serviceAdapter; } } throw new NakedObjectException("failed to find service for action " + this.getName()); }