public void addStationContainer(CStationContainer container) {
    if (container == null) throw new NullPointerException("container is null");
    if (containers.contains(container))
      throw new IllegalArgumentException("container already registered");

    for (CStationContainer child : containers) {
      if (child.getUniqueId().equals(container.getUniqueId())) {
        throw new IllegalArgumentException(
            "A container with unique id '" + container.getUniqueId() + "' is already registered");
      }
    }

    containers.add(container);

    try {
      settingDefaultStations = container == content;

      for (int i = 0, n = container.getStationCount(); i < n; i++) {
        control.addStation(container.getStation(i), true);
      }
    } finally {
      settingDefaultStations = false;
    }
    container.addStationContainerListener(containerListener);
  }
 public void added(CStationContainer source, CStation<?> station) {
   try {
     settingDefaultStations = source == content;
     control.addStation(station, true);
   } finally {
     settingDefaultStations = false;
   }
 }
 /**
  * Gets a list of all identifiers of {@link SingleCDockable} for which this control has location
  * information within the current {@link CControl#load(String) setting}.
  *
  * @return the list of ids, never <code>null</code>
  */
 public Set<String> listSingleDockables() {
   Set<String> result = new HashSet<String>();
   for (FrontendEntry entry : control.intern().listFrontendEntries()) {
     String id = entry.getKey();
     if (isSingleId(id)) {
       result.add(singleToNormalId(id));
     }
   }
   return result;
 }
  public boolean removeStationContainer(CStationContainer container) {
    if (containers.remove(container)) {
      container.removeStationContainerListener(containerListener);

      for (int i = 0, n = container.getStationCount(); i < n; i++) {
        control.removeStation(container.getStation(i));
      }
      return true;
    }
    return false;
  }
  public static void main(String[] args) {
    JTutorialFrame frame = new JTutorialFrame(PerspectivesHistory.class);
    CControl control = new CControl(frame);
    frame.destroyOnClose(control);

    /* When working with perspectives it is always a good idea first to set up the
     * CControl, then create the perspectives. */
    ColorFactory colorFactory = new ColorFactory();
    control.addSingleDockableFactory(colorFactory, colorFactory);
    control.addMultipleDockableFactory(CUSTOM_MULTI_FACTORY_ID, new CustomMultiFactory());

    /* By creating the root-stations now we automatically create counterparts in the
     * perspective. Otherwise we would need to do some setting up with the perspectives as
     * well. */
    frame.add(control.getContentArea(), BorderLayout.CENTER);
    control.createWorkingArea("work");

    /* Access to the perspective API */
    CControlPerspective perspectives = control.getPerspectives();

    /* Creating a new, empty perspective */
    CPerspective perspective = perspectives.createEmptyPerspective();

    /* For building up a history we need to move around CDockablePerspectives. It is
     * not possible to use several dockables with the same identifier. To make things
     * easier we just store the dockables in a map. In a real application you probably
     * want to implement a more advanced mechanism to store and access your dockables.
     *
     * IMPORTANT: the unique identifier of MultipleCDockablePerspectives is set by this method. */
    Map<String, CDockablePerspective> dockables = collect();

    /* We start by assigned the minimized location of all dockables. */
    setUpMinimized(perspective, dockables);
    /* Now we assign the normalized location of all dockables. */
    setUpNormalized(perspective, dockables);
    /* It is also possible to access and modify the location history directly. */
    modifyHistoryDirectly(perspective, dockables);
    /* At the end we set up the layout that the user will see when the application starts. */
    setUpFinalLayout(perspective, dockables);

    /* By calling "shrink" we instruct the perspective to remove unnecessary
     * PerspectiveStations from the layout. This is what the SingleParentRemover will do
     * with real DockStations. */
    perspective.shrink();

    /* Finally we apply the perspective we just created */
    perspectives.setPerspective(perspective, true);

    frame.setVisible(true);
  }
  public Dockabletest() {
    JTutorialFrame frame = new JTutorialFrame(Dockabletest.class);
    CControl control = new CControl(frame);
    frame.destroyOnClose(control);
    frame.add(control.getContentArea());
    frame.setBounds(260, 80, 900, 700);

    /*
     * We need to install our EditorFactory early on, otherwise the
     * framework will not allow us to register the EditorDockables.
     */
    control.addMultipleDockableFactory("file-editor", factory);

    /* We now create some dockables and drop them onto the content-area */
    CGrid grid = new CGrid(control);
    grid.add(0, 0, 1, 0.6, editorDockable1);
    grid.add(0, 0.6, 1, 0.4, editorDockable4);
    grid.add(1, 0, 1, 0.2, editorDockable2);
    grid.add(1, 0.2, 1, 0.3, editorDockable5);
    grid.add(1, 0.6, 1, 0.5, editorDockable3);
    control.getContentArea().deploy(grid);

    /*
     * The CLayoutChoiceMenuPiece creates a dynamic menu which allows us to
     * save and load the layout. In doing so we will use the EditorFactory.
     */
    // 给菜单栏添加菜单
    menuFile1.setFont(font);
    menuFile1.setPreferredSize(new Dimension(50, 25));
    menuFile2.setFont(font);
    menuFile2.setPreferredSize(new Dimension(80, 25));
    menuFile3.setFont(font);
    menuFile3.setPreferredSize(new Dimension(80, 25));
    menuFile4.setFont(font);
    menuFile4.setPreferredSize(new Dimension(100, 25));
    menuFile5.setFont(font);
    menuFile5.setPreferredSize(new Dimension(60, 25));
    menuFile6.setFont(font);
    menuFile6.setPreferredSize(new Dimension(50, 25));
    menubar.add(menuFile1);
    menubar.add(menuFile2);
    menubar.add(menuFile3);
    menubar.add(menuFile4);
    menubar.add(menuFile6);
    menubar.add(menuFile5);

    // 给菜单1添加子菜单
    newFile.setFont(font);
    menuFile1.add(newFile);
    newFile.addActionListener(this);
    menuFile1.add(openFile);
    openFile.addActionListener(this);
    openFile.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK));
    menuFile1.addSeparator();
    menuFile1.add(saveFile);
    saveFile.addActionListener(this);
    menuFile1.add(readFile);
    readFile.addActionListener(this);
    menuFile1.add(deleteFile);
    deleteFile.addActionListener(this);
    // 给菜单2添加子菜单
    menuFile2.add(tagging);
    tagging.addActionListener(this);
    tagging.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.CTRL_MASK));
    menuFile2.add(keyword);
    keyword.addActionListener(this);
    keyword.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_K, InputEvent.CTRL_MASK));
    menuFile2.add(keysentence);
    keysentence.addActionListener(this);
    keysentence.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK));
    menuFile2.add(summary);
    summary.addActionListener(this);
    summary.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK));
    menuFile2.addSeparator();
    menuFile2.add(all);
    all.addActionListener(this);
    // 给菜单3添加子菜单
    menuFile3.add(noun);
    noun.addActionListener(this);
    noun.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK));
    menuFile3.add(adjective);
    adjective.addActionListener(this);
    adjective.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK));
    menuFile3.add(adverb);
    adverb.addActionListener(this);
    adverb.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK));
    menuFile3.add(verb);
    verb.addActionListener(this);
    verb.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK));
    menuFile3.add(ncs);
    ncs.addActionListener(this);
    // 给菜单4添加子菜单
    menuFile4.add(mKeyword);
    mKeyword.addActionListener(this);
    mKeyword.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK));
    menuFile4.add(mSentence);
    mSentence.addActionListener(this);
    mSentence.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_M, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK));
    menuFile4.add(mSummary);
    mSummary.addActionListener(this);
    mSummary.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK));
    // 给菜单5添加子菜单
    menuFile5.add(wtCollection);
    wtCollection.addActionListener(this);
    menuFile5.add(addCharacteristic);
    addCharacteristic.addActionListener(this);
    menuFile5.add(clearData);
    clearData.addActionListener(this);
    menuFile5.addSeparator();
    menuFile5.add(showAll);
    showAll.addActionListener(this);
    menuFile5.addSeparator();
    menuFile5.add(test);
    test.addActionListener(this);
    menuFile5.add(setWordCol);
    setWordCol.addActionListener(this);
    menuFile5.addSeparator();
    menuFile5.add(setCorpusType);
    setCorpusType.addActionListener(this);
    // 给菜单6添加子菜单
    menuFile6.add(revokeKeyword);
    revokeKeyword.addActionListener(this);
    menuFile6.add(revokeSentence);
    revokeSentence.addActionListener(this);
    menuFile6.add(revokeSummary);
    revokeSummary.addActionListener(this);
    menuFile6.add(revokeTagging);
    revokeTagging.addActionListener(this);
    // 设置fileContent文本字体
    editorDockable1.text.setFont(font1);
    editorDockable2.text.setFont(font1);
    editorDockable3.text.setFont(font1);
    editorDockable4.text.setFont(font1);
    editorDockable5.text.setFont(font1);
    frame.setJMenuBar(menubar);

    UIManager.put("OptionPane.messageFont", font);
    UIManager.put("OptionPane.buttonFont", font);

    editorDockable2.text.setEditable(false);
    editorDockable3.text.setEditable(false);
    editorDockable4.text.setEditable(false);
    /* and finally we can start the application */
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
  }
 public void removed(CStationContainer source, CStation<?> station) {
   control.removeStation(station);
 }