예제 #1
0
  private TreeModel buildModel(Object[] resolvers) {
    TreeModel fullModel = null;
    DefaultMutableTreeNode top = new DefaultMutableTreeNode(Tr.t("root"));

    try {
      cpos = null;
      for (Object resolver : resolvers) {
        if (resolver instanceof ColorPository) {
          cpos = (ColorPository) resolver;
          GraphCellRenderer graphCellRenderer = new GraphCellRenderer(cpos);
          colors.setCellRenderer(graphCellRenderer);
          break;
        }
      }
      Collection<ColorPository.ClassRecord> classes = cpos.getClasses();
      String[] classNames = new String[classes.size()];
      Iterator<ColorPository.ClassRecord> it = classes.iterator();
      int count = 0;
      while (it.hasNext()) {
        classNames[count] = it.next().name;
        count++;
      }
      Arrays.sort(classNames);

      for (String className : classNames) {
        ColorPository.ColorRecord[] colors = cpos.enumerateColors(className);
        String[] colorNames = new String[colors.length];
        for (int a = 0; a < colorNames.length; a++) {
          colorNames[a] = colors[a].name;
        }
        Arrays.sort(colorNames);

        DefaultMutableTreeNode tn = new DefaultMutableTreeNode(className);
        top.add(tn);
        for (String colorName : colorNames) {
          tn.add(new DefaultMutableTreeNode(colorName));
        }
      }

      fullModel = new DefaultTreeModel(top);
    } catch (Exception e) {
      fullModel = new DefaultTreeModel(new DefaultMutableTreeNode(Tr.t("root.failed")));
      // e.printStackTrace();
    }
    return fullModel;
  }
예제 #2
0
    public void add(long time) {
      // May need to store a new time offset
      int n = offsets.length;
      if (n == 0 || time - offsets[n - 1] > Integer.MAX_VALUE) {
        // Grow offset and indices arrays and store new offset
        offsets = Arrays.copyOf(offsets, n + 1);
        offsets[n] = time;
        indices = Arrays.copyOf(indices, n + 1);
        indices[n] = size;
      }

      // May need to extend the array size
      if (rtimes.length == size) {
        rtimes = (int[]) extendArray(rtimes);
      }

      // Store the time
      rtimes[size] = (int) (time - offsets[offsets.length - 1]);
      size++;
    }
 @Override
 public String batchDelete(
     Model model,
     @RequestParam("items") Long[] items,
     HttpServletRequest request,
     HttpServletResponse response)
     throws RebirthException {
   List<CircleTopicEntity> list =
       circleService.findByIds(CircleTopicEntity.class, Arrays.asList(items));
   circleService.delete(list);
   return "circle/circleDeatil";
 }
예제 #4
0
 public FormProperty<?>[] getAllProperties() {
   if (layoutDelegate instanceof AbstractLayoutSupport) {
     return ((AbstractLayoutSupport) layoutDelegate).getAllProperties();
   }
   java.util.List<FormProperty<?>> allPropsList = new ArrayList<>();
   for (Node.PropertySet propertySet : propertySets) {
     FormProperty<?>[] props = (FormProperty<?>[]) propertySet.getProperties();
     allPropsList.addAll(Arrays.asList(props));
   }
   FormProperty<?>[] allProperties = new FormProperty<?>[allPropsList.size()];
   allPropsList.toArray(allProperties);
   return allProperties;
 }
  protected static String getStatusToolTip() {
    StringBuffer result = new StringBuffer("<html>"); // NOI18N
    result.append("<table cellspacing=\"0\" border=\"0\">"); // NOI18N

    final CollabManager manager = CollabManager.getDefault();

    if (manager != null) {
      Set sessions =
          new TreeSet(
              new Comparator() {
                public int compare(Object o1, Object o2) {
                  String s1 = ((CollabSession) o1).getUserPrincipal().getDisplayName();
                  String s2 = ((CollabSession) o2).getUserPrincipal().getDisplayName();

                  return s1.compareTo(s2);
                }
              });

      sessions.addAll(Arrays.asList(manager.getSessions()));

      if (sessions.size() == 0) {
        result.append("<tr><td>"); // NOI18N
        result.append(getStatusDescription(CollabPrincipal.STATUS_OFFLINE));
        result.append("</td></tr>"); // NOI18N
      } else {
        for (Iterator i = sessions.iterator(); i.hasNext(); ) {
          CollabPrincipal principal = ((CollabSession) i.next()).getUserPrincipal();

          result.append("<tr>"); // NOI18N
          result.append("<td>"); // NOI18N
          result.append("<b>"); // NOI18N
          result.append(principal.getDisplayName());
          result.append(": "); // NOI18N
          result.append("</b>"); // NOI18N
          result.append("</td>"); // NOI18N
          result.append("<td>"); // NOI18N
          result.append(getStatusDescription(principal.getStatus()));
          result.append("</td>"); // NOI18N
          result.append("</tr>"); // NOI18N
        }
      }
    }

    result.append("</table>"); // NOI18N

    return result.toString();
  }
예제 #6
0
    public void actionPerformed(ActionEvent e) {
      if (!this.isEnabled()) {
        return;
      }

      if (NEW_AIRSPACE.equals(e.getActionCommand())) {
        this.createNewEntry(this.getView().getSelectedFactory());
      } else if (CLEAR_SELECTION.equals(e.getActionCommand())) {
        this.selectEntry(null, true);
      } else if (SIZE_NEW_SHAPES_TO_VIEWPORT.equals(e.getActionCommand())) {
        if (e.getSource() instanceof AbstractButton) {
          boolean selected = ((AbstractButton) e.getSource()).isSelected();
          this.setResizeNewShapesToViewport(selected);
        }
      } else if (ENABLE_EDIT.equals(e.getActionCommand())) {
        if (e.getSource() instanceof AbstractButton) {
          boolean selected = ((AbstractButton) e.getSource()).isSelected();
          this.setEnableEdit(selected);
        }
      } else if (OPEN.equals(e.getActionCommand())) {
        this.openFromFile();
      } else if (OPEN_URL.equals(e.getActionCommand())) {
        this.openFromURL();
      } else if (OPEN_DEMO_AIRSPACES.equals(e.getActionCommand())) {
        this.openFromPath(DEMO_AIRSPACES_PATH);
        this.zoomTo(
            LatLon.fromDegrees(47.6584074779224, -122.3059199579634),
            Angle.fromDegrees(-152),
            Angle.fromDegrees(75),
            750);
      } else if (REMOVE_SELECTED.equals(e.getActionCommand())) {
        this.removeEntries(Arrays.asList(this.getSelectedEntries()));
      } else if (SAVE.equals(e.getActionCommand())) {
        this.saveToFile();
      } else if (SELECTION_CHANGED.equals(e.getActionCommand())) {
        this.viewSelectionChanged();
      }
    }
예제 #7
0
    public void actionPerformed(ActionEvent e) {
      if (isDirectorySelected()) {
        File dir = getDirectory();
        if (dir != null) {
          try {
            // Strip trailing ".."
            dir = ShellFolder.getNormalizedFile(dir);
          } catch (IOException ex) {
            // Ok, use f as is
          }
          changeDirectory(dir);
          return;
        }
      }

      JFileChooser chooser = getFileChooser();

      String filename = getFileName();
      FileSystemView fs = chooser.getFileSystemView();
      File dir = chooser.getCurrentDirectory();

      if (filename != null) {
        // Remove whitespaces from end of filename
        int i = filename.length() - 1;

        while (i >= 0 && filename.charAt(i) <= ' ') {
          i--;
        }

        filename = filename.substring(0, i + 1);
      }

      if (filename == null || filename.length() == 0) {
        // no file selected, multiple selection off, therefore cancel the approve action
        resetGlobFilter();
        return;
      }

      File selectedFile = null;
      File[] selectedFiles = null;

      // Unix: Resolve '~' to user's home directory
      if (File.separatorChar == '/') {
        if (filename.startsWith("~/")) {
          filename = System.getProperty("user.home") + filename.substring(1);
        } else if (filename.equals("~")) {
          filename = System.getProperty("user.home");
        }
      }

      if (chooser.isMultiSelectionEnabled()
          && filename.length() > 1
          && filename.charAt(0) == '"'
          && filename.charAt(filename.length() - 1) == '"') {
        List<File> fList = new ArrayList<File>();

        String[] files = filename.substring(1, filename.length() - 1).split("\" \"");
        // Optimize searching files by names in "children" array
        Arrays.sort(files);

        File[] children = null;
        int childIndex = 0;

        for (String str : files) {
          File file = fs.createFileObject(str);
          if (!file.isAbsolute()) {
            if (children == null) {
              children = fs.getFiles(dir, false);
              Arrays.sort(children);
            }
            for (int k = 0; k < children.length; k++) {
              int l = (childIndex + k) % children.length;
              if (children[l].getName().equals(str)) {
                file = children[l];
                childIndex = l + 1;
                break;
              }
            }
          }
          fList.add(file);
        }

        if (!fList.isEmpty()) {
          selectedFiles = fList.toArray(new File[fList.size()]);
        }
        resetGlobFilter();
      } else {
        selectedFile = fs.createFileObject(filename);
        if (!selectedFile.isAbsolute()) {
          selectedFile = fs.getChild(dir, filename);
        }
        // check for wildcard pattern
        FileFilter currentFilter = chooser.getFileFilter();
        if (!selectedFile.exists() && isGlobPattern(filename)) {
          changeDirectory(selectedFile.getParentFile());
          if (globFilter == null) {
            globFilter = new GlobFilter();
          }
          try {
            globFilter.setPattern(selectedFile.getName());
            if (!(currentFilter instanceof GlobFilter)) {
              actualFileFilter = currentFilter;
            }
            chooser.setFileFilter(null);
            chooser.setFileFilter(globFilter);
            return;
          } catch (PatternSyntaxException pse) {
            // Not a valid glob pattern. Abandon filter.
          }
        }

        resetGlobFilter();

        // Check for directory change action
        boolean isDir = (selectedFile != null && selectedFile.isDirectory());
        boolean isTrav = (selectedFile != null && chooser.isTraversable(selectedFile));
        boolean isDirSelEnabled = chooser.isDirectorySelectionEnabled();
        boolean isFileSelEnabled = chooser.isFileSelectionEnabled();
        boolean isCtrl =
            (e != null
                && (e.getModifiers() & Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0);

        if (isDir && isTrav && (isCtrl || !isDirSelEnabled)) {
          changeDirectory(selectedFile);
          return;
        } else if ((isDir || !isFileSelEnabled)
            && (!isDir || !isDirSelEnabled)
            && (!isDirSelEnabled || selectedFile.exists())) {
          selectedFile = null;
        }
      }

      if (selectedFiles != null || selectedFile != null) {
        if (selectedFiles != null || chooser.isMultiSelectionEnabled()) {
          if (selectedFiles == null) {
            selectedFiles = new File[] {selectedFile};
          }
          chooser.setSelectedFiles(selectedFiles);
          // Do it again. This is a fix for bug 4949273 to force the
          // selected value in case the ListSelectionModel clears it
          // for non-existing file names.
          chooser.setSelectedFiles(selectedFiles);
        } else {
          chooser.setSelectedFile(selectedFile);
        }
        chooser.approveSelection();
      } else {
        if (chooser.isMultiSelectionEnabled()) {
          chooser.setSelectedFiles(null);
        } else {
          chooser.setSelectedFile(null);
        }
        chooser.cancelSelection();
      }
    }
예제 #8
0
  /**
   * Standard constructor.
   *
   * @param type Type that you are going to be creating and editor for.
   * @param readOnly Set to true to create a read-only customizer.
   */
  public DynamicCustomizer(Class type, boolean readOnly) {
    super(new GridBagLayout());
    _readOnly = readOnly;
    _type = type;

    LabelFieldGBC gbc = new LabelFieldGBC();
    try {
      BeanInfo info = Introspector.getBeanInfo(type);
      // Set up pretty display stuff.
      setBorder(BorderFactory.createTitledBorder(info.getBeanDescriptor().getDisplayName()));
      setToolTipText(info.getBeanDescriptor().getShortDescription());

      // Get the properties and sort them.
      PropertyDescriptor[] props = info.getPropertyDescriptors();
      Arrays.sort(props, new PropertyComparator());
      for (int i = 0; i < props.length; i++) {
        // Ignore the "class" property, if it is provided.
        if (props[i].getName().equals("class")) continue;
        // Create a label for the field.
        JLabel label = new JLabel(props[i].getDisplayName() + ":");

        // Lookup the editor.
        PropertyEditor editor = getEditorForProperty(props[i]);

        // Add a listener to the editor so we know when to update
        // the bean's fields.
        editor.addPropertyChangeListener(_eListener);

        // XXX What we need to do right here is provide a component
        // that makes use of the "paintable" capability of the editor.
        Component comp = editor.getCustomEditor();
        if (comp == null) {
          comp = new JLabel("<No editor available.>");
          ((JLabel) comp).setBorder(BorderFactory.createEtchedBorder());
        }

        // See if it is a read-only property. If so, then just
        // display it.
        if (_readOnly || props[i].getWriteMethod() == null) {
          comp.setEnabled(false);
        }

        // Setup the accellerator key.
        label.setLabelFor(comp);
        label.setDisplayedMnemonic(label.getText().charAt(0));

        // Set the tool tip text, if any.
        String tip = props[i].getShortDescription();
        if (tip != null) {
          label.setToolTipText(tip);
          if (comp instanceof JComponent) {
            ((JComponent) comp).setToolTipText(tip);
          }
        }

        // Add the label and fields.
        add(label, gbc.forLabel());
        add(comp, gbc.forField());

        // Set the mappings between editor and property, etc. for
        // quick lookup later.
        _prop2Editor.put(props[i], editor);
        _editor2Prop.put(editor, props[i]);
      }
      // Filler...
      add(new JLabel(), gbc.forLastLabel());

    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }