Пример #1
0
  /** Update the arrow head type on the currently selected links. */
  private void onUpdateArrowType(int nArrowType) {
    if (!bJustSetting) {

      UIViewFrame frame = ProjectCompendium.APP.getCurrentFrame();
      Model oModel = (Model) ProjectCompendium.APP.getModel();
      if (frame instanceof UIMapViewFrame) {

        Vector vtUpdateLinks = new Vector();
        UIMapViewFrame oMapFrame = (UIMapViewFrame) frame;
        UIViewPane pane = oMapFrame.getViewPane();
        UILink link = null;
        LinkProperties props = null;
        for (Enumeration e = pane.getSelectedLinks(); e.hasMoreElements(); ) {
          link = (UILink) e.nextElement();
          props = link.getLinkProperties();
          if (nArrowType != props.getArrowType()) {
            vtUpdateLinks.addElement(props);
          }
        }
        if (vtUpdateLinks.size() > 0) {
          try {
            ((ViewService) oModel.getViewService())
                .setArrowType(
                    oModel.getSession(), pane.getView().getId(), vtUpdateLinks, nArrowType);
            int count = vtUpdateLinks.size();
            for (int i = 0; i < count; i++) {
              props = (LinkProperties) vtUpdateLinks.elementAt(i);
              props.setArrowType(nArrowType);
            }
          } catch (SQLException ex) {
            ProjectCompendium.APP.displayError(
                LanguageProperties.getString(
                        LanguageProperties.TOOLBARS_BUNDLE,
                        "UIToolBarFormatLink.unableUpdateArrowType")
                    + ":\n\n"
                    + ex.getMessage()); // $NON-NLS-1$
          }
        }
      }
    }
  }
Пример #2
0
  /**
   * Does Nothing
   *
   * @param selected, true to enable, false to disable.
   */
  public void setNodeOrLinkSelected(boolean selected) {
    if (tbrToolBar != null) {

      UIViewFrame frame = ProjectCompendium.APP.getCurrentFrame();
      if (selected && frame instanceof UIMapViewFrame) {
        UIMapViewFrame oMapFrame = (UIMapViewFrame) frame;
        UIViewPane pane = oMapFrame.getViewPane();

        int nLinkCount = pane.getNumberOfSelectedLinks();
        if (nLinkCount == 0) return;

        bJustSetting = true;

        int i = 0;
        UILink link = null;
        LinkProperties linkProps = null;
        boolean bDefaultLinkStyle = false;
        boolean bDefaultLinkDashed = false;
        boolean bDefaultLinkWeight = false;
        boolean bDefaultLinkColour = false;
        boolean bDefaultArrowType = false;

        LinkProperties defaultprops = UIUtilities.getLinkProperties("");
        int linkstyle = defaultprops.getLinkStyle();
        int linkdashed = defaultprops.getLinkDashed();
        int linkweight = defaultprops.getLinkWeight();
        int linkcolour = defaultprops.getLinkColour();
        int arrowtype = defaultprops.getArrowType();

        for (Enumeration e = pane.getSelectedLinks(); e.hasMoreElements(); ) {
          link = (UILink) e.nextElement();
          linkProps = link.getLinkProperties();
          if (i == 0) {
            linkstyle = linkProps.getLinkStyle();
            linkdashed = linkProps.getLinkDashed();
            linkweight = linkProps.getLinkWeight();
            linkcolour = linkProps.getLinkColour();
            arrowtype = linkProps.getArrowType();
            i++;
          } else {
            if (arrowtype != linkProps.getArrowType()) {
              bDefaultArrowType = true;
            }
            if (linkstyle != linkProps.getLinkStyle()) {
              bDefaultLinkStyle = true;
            }
            if (linkdashed != linkProps.getLinkDashed()) {
              bDefaultLinkDashed = true;
            }
            if (linkweight != linkProps.getLinkWeight()) {
              bDefaultLinkWeight = true;
            }
            if (linkcolour != linkProps.getLinkColour()) {
              bDefaultLinkColour = true;
            }
          }
        }

        tbrToolBar.setEnabled(true);

        if (bDefaultLinkColour) {
          selectedLinkColour = new Color(defaultprops.getLinkColour());
        } else {
          selectedLinkColour = new Color(linkcolour);
        }

        linkColourPanel.setEnabled(true);
        txtLinkColour.setEnabled(true);

        cbLineWeight.setEnabled(true);
        if (bDefaultLinkWeight) {
          cbLineWeight.setSelectedIndex(defaultprops.getLinkWeight() - 1);
        } else {
          cbLineWeight.setSelectedIndex(linkweight - 1);
        }

        cbArrows.setEnabled(true);
        if (bDefaultArrowType) {
          cbArrows.setSelectedIndex(defaultprops.getArrowType());
        } else {
          cbArrows.setSelectedIndex(arrowtype);
        }

        cbLinkStyle.setEnabled(true);
        if (bDefaultLinkStyle) {
          cbLinkStyle.setSelectedIndex(defaultprops.getLinkStyle());
        } else {
          cbLinkStyle.setSelectedIndex(linkstyle);
        }

        cbLinkDashed.setEnabled(true);
        if (bDefaultLinkDashed) {
          cbLinkDashed.setSelectedIndex(defaultprops.getLinkDashed());
        } else {
          cbLinkDashed.setSelectedIndex(linkdashed);
        }

        bJustSetting = false;

      } else if (!selected) {

        bJustSetting = true;

        linkColourPanel.setEnabled(false);
        txtLinkColour.setEnabled(false);
        tbrToolBar.setEnabled(false);
        cbArrows.setEnabled(false);
        cbLineWeight.setEnabled(false);
        cbLinkStyle.setEnabled(false);
        cbLinkDashed.setEnabled(false);

        bJustSetting = false;
      }
    }
  }