bibliothek.gui.dock.common.DefaultSingleCDockable Java Examples

The following examples show how to use bibliothek.gui.dock.common.DefaultSingleCDockable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DockingManager.java    From openAGV with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new dockable.
 *
 * @param id The unique id for this dockable.
 * @param title The title text of this new dockable.
 * @param comp The JComponent wrapped by the new dockable.
 * @param closeable If the dockable can be closeable or not.
 * @return The newly created dockable.
 */
public DefaultSingleCDockable createDockable(String id,
                                             String title,
                                             JComponent comp,
                                             boolean closeable) {
  Objects.requireNonNull(id, "id is null");
  Objects.requireNonNull(title, "title is null");
  Objects.requireNonNull(comp, "comp is null");
  if (control == null) {
    return null;
  }
  DefaultSingleCDockable dockable = new DefaultSingleCDockable(id, title);
  dockable.setCloseable(closeable);
  dockable.add(comp);
  return dockable;
}
 
Example #2
Source File: DockingFrame.java    From Rails with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Registers a component that is to become a dockable.
 * The dockable is only deployed to the frame if deployDockables is called.
 */
protected void addDockable(JComponent c,
        String dockableConfigKey,
        int x, int y, int width, int height,
        DockableProperty dockableProperty) {
    String dockableTitle = LocalText.getText(dockableConfigKey);
    DefaultSingleCDockable d = new DefaultSingleCDockable(
            dockableTitle, dockableTitle );
    d.add( c, BorderLayout.CENTER );
    d.setTitleIcon(RailsIcon.getByConfigKey(dockableConfigKey).smallIcon);
    d.setCloseable(
            (  dockableProperty == DockableProperty.CLOSEABLE
            || dockableProperty == DockableProperty.INITIALLY_HIDDEN)
    );
    gridLayout.add( x, y, width, height, d );
    dockables.add(d);
    if (dockableProperty == DockableProperty.INITIALLY_HIDDEN ) {
        dockables_initiallyHidden.add(d);
    }
}
 
Example #3
Source File: OpenTCSView.java    From openAGV with Apache License 2.0 6 votes vote down vote up
private void restoreDockables() {
  // --- DrawingView for modelling ---
  DefaultSingleCDockable modellingDockable = addDrawingView();
  viewManager.initModellingDockable(
      modellingDockable,
      bundle.getString("openTcsView.panel_modellingDrawingView.title"));

  addDrawingView();

  addTransportOrderView();
  addTransportOrderSequenceView();

  dockingManager.getTabPane(DockingManager.COURSE_TAB_PANE_ID)
      .getStation()
      .setFrontDockable(viewManager.evaluateFrontDockable());
}
 
Example #4
Source File: OpenTCSView.java    From openAGV with Apache License 2.0 6 votes vote down vote up
private void removeDrawingView(DefaultSingleCDockable dock) {
  if (!viewManager.getDrawingViewMap().containsKey(dock)) {
    return;
  }

  // Remove from group pop ups
  ModelComponent groups = fModelManager.getModel().getMainFolder(SystemModel.FolderKey.GROUPS);
  for (Object o : groups.getChildComponents()) {
    if (o instanceof GroupModel) {
      GroupModel gf = (GroupModel) o;
      gf.removeDrawingView(dock.getTitleText());
    }
  }
  fDrawingEditor.remove(viewManager.getDrawingViewMap().get(dock).getDrawingView());
  viewManager.removeDockable(dock);
  dockingManager.removeDockable(dock);
}
 
Example #5
Source File: ViewManager.java    From openAGV with Apache License 2.0 6 votes vote down vote up
/**
 * Forgets the given dockable.
 *
 * @param dockable The dockable.
 */
public void removeDockable(DefaultSingleCDockable dockable) {
  DrawingViewScrollPane scrollPane = drawingViewMap.remove(dockable);
  if (scrollPane != null) {
    eventSource.unsubscribe(scrollPane.getDrawingView());
  }

  TransportOrdersContainerPanel ordersPanel = transportOrderViews.remove(dockable);
  if (ordersPanel != null) {
    eventSource.unsubscribe(ordersPanel);
  }

  OrderSequencesContainerPanel sequencePanel = orderSequenceViews.remove(dockable);
  if (sequencePanel != null) {
    eventSource.unsubscribe(sequencePanel);
  }
}
 
Example #6
Source File: ViewManager.java    From openAGV with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the next available index of a set of dockables.
 * E.g. if "Dock 0" and "Dock 2" are being used, 1 would be returned.
 *
 * @param setToIterate The set to iterate.
 * @return The next available index.
 */
private int nextAvailableIndex(Set<DefaultSingleCDockable> setToIterate) {
  // Name
  Pattern p = Pattern.compile("\\d");
  Matcher m;
  int biggestIndex = 0;

  for (DefaultSingleCDockable dock : setToIterate) {
    m = p.matcher(dock.getTitleText());

    if (m.find()) {
      int index = Integer.parseInt(m.group(0));

      if (index > biggestIndex) {
        biggestIndex = index;
      }
    }
  }

  return biggestIndex + 1;
}
 
Example #7
Source File: DockingManager.java    From openAGV with Apache License 2.0 5 votes vote down vote up
/**
 * Hides a dockable (by actually removing it from its station).
 *
 * @param station The CStackDockStation the dockable belongs to.
 * @param dockable The dockable to hide.
 */
public void hideDockable(CStackDockStation station, DefaultSingleCDockable dockable) {
  int index = station.indexOf(dockable.intern());

  if (index <= -1) {
    station.add(dockable.intern(), station.getDockableCount());
    index = station.indexOf(dockable.intern());
  }
  station.remove(index);
}
 
Example #8
Source File: DockingManager.java    From openAGV with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a dockable as tab to the tab pane identified by the given id.
 *
 * @param newTab The new dockable that shall be added.
 * @param id The ID of the tab pane.
 * @param index Index where to insert the dockable in the tab pane.
 */
public void addTabTo(DefaultSingleCDockable newTab, String id, int index) {
  Objects.requireNonNull(newTab, "newTab is null.");
  Objects.requireNonNull(id, "id is null");
  CStack tabPane = tabPanes.get(id);
  if (tabPane != null) {
    control.addDockable(newTab);
    newTab.setWorkingArea(tabPane);
    tabPane.getStation().add(newTab.intern(), index);
    tabPane.getStation().setFrontDockable(newTab.intern());
  }
}
 
Example #9
Source File: DockingManager.java    From openAGV with Apache License 2.0 5 votes vote down vote up
/**
 * Shows a dockable (by actually adding it to its station).
 *
 * @param station The CStackDockStation the dockable belongs to.
 * @param dockable The dockable to show.
 * @param index Where to add the dockable.
 */
public void showDockable(CStackDockStation station,
                         DefaultSingleCDockable dockable,
                         int index) {
  if (station.indexOf(dockable.intern()) <= -1) {
    station.add(dockable.intern(), index);
  }
}
 
Example #10
Source File: DockableClosingHandler.java    From openAGV with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance.
 *
 * @param dockable The dockable.
 * @param viewManager Manages the application's views.
 * @param dockingManager Manages the application's dockables.
 */
@Inject
public DockableClosingHandler(@Assisted DefaultSingleCDockable dockable,
                              ViewManager viewManager,
                              DockingManager dockingManager) {
  this.dockable = requireNonNull(dockable, "dockable");
  this.viewManager = requireNonNull(viewManager, "viewManager");
  this.dockingManager = requireNonNull(dockingManager, "dockingManager");
}
 
Example #11
Source File: DockingManager.java    From openAGV with Apache License 2.0 5 votes vote down vote up
/**
 * Fires a <code>PropertyChangeEvent</code> when a floatable dockable is closed
 * (eg a plugin panel).
 *
 * @param dockable The dockable that was closed.
 */
private void fireFloatingDockableClosed(DefaultSingleCDockable dockable) {
  for (PropertyChangeListener listener : listeners) {
    listener.propertyChange(
        new PropertyChangeEvent(this, DOCKABLE_CLOSED, dockable, dockable));
  }
}
 
Example #12
Source File: OpenTCSView.java    From openAGV with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a new order sequence view.
 */
public void addTransportOrderSequenceView() {
  int biggestIndex = viewManager.getNextOrderSequenceViewIndex();
  DefaultSingleCDockable lastOSView = viewManager.getLastOrderSequenceView();

  OrderSequencesContainerPanel panel = osContainerPanelProvider.get();
  DefaultSingleCDockable newDockable
      = dockingManager.createDockable("orderSequences" + biggestIndex,
                                      bundle.getString(
                                          "openTcsView.panel_operatingOrderSequencesView.title")
                                      + " " + biggestIndex,
                                      panel, true);
  viewManager.addOrderSequenceView(newDockable, panel);

  panel.initView();

  newDockable.addVetoClosingListener(
      dockableHandlerFactory.createDockableClosingHandler(newDockable));

  final int indexToInsert;
  if (lastOSView != null) {
    indexToInsert = dockingManager
        .getTabPane(DockingManager.COURSE_TAB_PANE_ID)
        .getStation()
        .indexOf(lastOSView.intern()) + 1;
  }
  else {
    indexToInsert = viewManager.getTransportOrderMap().size()
        + viewManager.getDrawingViewMap().size();
  }
  dockingManager.addTabTo(newDockable, DockingManager.COURSE_TAB_PANE_ID, indexToInsert);
}
 
Example #13
Source File: OpenTCSView.java    From openAGV with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a new transport order view.
 */
public void addTransportOrderView() {
  int biggestIndex = viewManager.getNextTransportOrderViewIndex();
  DefaultSingleCDockable lastTOView = viewManager.getLastTransportOrderView();
  TransportOrdersContainerPanel panel = toContainerPanelProvider.get();
  DefaultSingleCDockable newDockable
      = dockingManager.createDockable("transportOrders" + biggestIndex,
                                      bundle.getString(
                                          "openTcsView.panel_operatingTransportOrdersView.title")
                                      + " " + biggestIndex, panel, true);
  viewManager.addTransportOrderView(newDockable, panel);

  panel.initView();

  newDockable.addVetoClosingListener(
      dockableHandlerFactory.createDockableClosingHandler(newDockable));

  final int indexToInsert;

  if (lastTOView != null) {
    indexToInsert = dockingManager
        .getTabPane(DockingManager.COURSE_TAB_PANE_ID)
        .getStation()
        .indexOf(lastTOView.intern()) + 1;
  }
  else {
    indexToInsert = viewManager.getDrawingViewMap().size();
  }

  dockingManager.addTabTo(newDockable, DockingManager.COURSE_TAB_PANE_ID, indexToInsert);
}
 
Example #14
Source File: GuiUtil.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Create dockable
 * @param title
 * @param color
 * @return 
 */
public static SingleCDockable createDockable(String title, Color color) {
    JPanel panel = new JPanel();
    panel.setOpaque(true);
    panel.setBackground(color);
    DefaultSingleCDockable dockable = new DefaultSingleCDockable(title, title, panel);
    dockable.setCloseable(true);
    return dockable;
}
 
Example #15
Source File: ViewManager.java    From openAGV with Apache License 2.0 5 votes vote down vote up
/**
 * Puts a <code>OrderSequencesContainerPanel</code> with a key dockable
 * into the order sequence view map.
 *
 * @param dockable The dockable the panel is wrapped into. Used as the key.
 * @param panel The panel.
 */
public void addOrderSequenceView(DefaultSingleCDockable dockable,
                                 OrderSequencesContainerPanel panel) {
  requireNonNull(dockable, "dockable");
  requireNonNull(panel, "panel");

  eventSource.subscribe(panel);
  orderSequenceViews.put(dockable, panel);
}
 
Example #16
Source File: ViewManager.java    From openAGV with Apache License 2.0 5 votes vote down vote up
/**
 * Puts a <code>TransportOrdersContainerPanel</code> with a key dockable
 * into the transport order view map.
 *
 * @param dockable The dockable the panel is wrapped into. Used as the key.
 * @param panel The panel.
 */
public void addTransportOrderView(DefaultSingleCDockable dockable,
                                  TransportOrdersContainerPanel panel) {
  requireNonNull(dockable, "dockable");
  requireNonNull(panel, "panel");

  eventSource.subscribe(panel);
  transportOrderViews.put(dockable, panel);
}
 
Example #17
Source File: ViewManager.java    From openAGV with Apache License 2.0 5 votes vote down vote up
/**
 * Puts a scroll pane with a key dockable into the drawing view map.
 * The scroll pane has to contain the drawing view and both rulers.
 *
 * @param dockable The dockable the scrollPane is wrapped into. Used as the key.
 * @param scrollPane The scroll pane containing the drawing view and rulers.
 */
public void addDrawingView(DefaultSingleCDockable dockable,
                           DrawingViewScrollPane scrollPane) {
  requireNonNull(dockable, "dockable");
  requireNonNull(scrollPane, "scrollPane");

  eventSource.subscribe(scrollPane.getDrawingView());
  drawingViewMap.put(dockable, scrollPane);
}
 
Example #18
Source File: ViewManager.java    From openAGV with Apache License 2.0 5 votes vote down vote up
public DefaultSingleCDockable getLastOrderSequenceView() {
  int biggestIndex = getNextOrderSequenceViewIndex();
  DefaultSingleCDockable lastOSView = null;
  Iterator<DefaultSingleCDockable> orderSequencesViewIterator
      = orderSequenceViews.keySet().iterator();
  for (int i = 0; i < biggestIndex; i++) {
    if (orderSequencesViewIterator.hasNext()) {
      lastOSView = orderSequencesViewIterator.next();
    }
  }

  return lastOSView;
}
 
Example #19
Source File: ViewManager.java    From openAGV with Apache License 2.0 5 votes vote down vote up
public DefaultSingleCDockable getLastTransportOrderView() {
  int biggestIndex = getNextTransportOrderViewIndex();
  DefaultSingleCDockable lastTOView = null;
  Iterator<DefaultSingleCDockable> tranportOrderViewIterator
      = transportOrderViews.keySet().iterator();
  for (int i = 0; i < biggestIndex; i++) {
    if (tranportOrderViewIterator.hasNext()) {
      lastTOView = tranportOrderViewIterator.next();
    }
  }

  return lastTOView;
}
 
Example #20
Source File: GuiUtil.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Create editor dockable
 * @param title Title
 * @return Editor dockable
 */
public static SingleCDockable createEditorDockable(String title) {
    JTabbedPane tabbedPanel = new JTabbedPane(); 
    addNewTextEditor("New", tabbedPanel);
    DefaultSingleCDockable dockable = new DefaultSingleCDockable(title, title, tabbedPanel);
    dockable.setCloseable(true);
    return dockable;
}
 
Example #21
Source File: DockingFrame.java    From Rails with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Ensure that externalized dockable does not have default maximize button
 * (as it won't work for the adjusted externalization setup).
 * @param d Dockable for which the actions are to be adjusted
 */
private void adjustExternalizedActions(CDockable d) {
    if (d instanceof DefaultSingleCDockable) {
        DefaultSingleCDockable sd = (DefaultSingleCDockable)d;
        if (ExtendedMode.EXTERNALIZED.equals(sd.getExtendedMode())) {
            sd.putAction( CDockable.ACTION_KEY_MAXIMIZE, CBlank.BLANK );
        } else {
            sd.putAction( CDockable.ACTION_KEY_MAXIMIZE, null );
        }
    }
}
 
Example #22
Source File: GUIPluginFactory.java    From ramus with GNU General Public License v3.0 5 votes vote down vote up
public DefaultSingleCDockable findUniqueDockable(String id) {
    for (DefaultSingleCDockable dockable : uniqueDockables) {
        if (dockable.getUniqueId().equals(id))
            return dockable;
    }
    return null;
}
 
Example #23
Source File: ViewManager.java    From openAGV with Apache License 2.0 4 votes vote down vote up
public Map<DefaultSingleCDockable, DrawingViewScrollPane> getDrawingViewMap() {
  return drawingViewMap;
}
 
Example #24
Source File: DockingManager.java    From openAGV with Apache License 2.0 4 votes vote down vote up
/**
 * Wraps all given JComponents into a dockable and deploys them on the CControl.
 *
 * @param frame
 * @param vehiclesPanel
 * @param fTreeView
 * @param fBlocksView
 * @param fGroupsView
 * @param fPropertiesComponent
 * @param statusScrollPane
 */
public void initializeDockables(JFrame frame,
                                JComponent vehiclesPanel,
                                TreeView fTreeView,
                                TreeView fBlocksView,
                                TreeView fGroupsView,
                                JComponent fPropertiesComponent,
                                JComponent statusScrollPane) {
  Objects.requireNonNull(frame, "frame is null");
  Objects.requireNonNull(vehiclesPanel, "vehiclesPane is null");
  Objects.requireNonNull(fTreeView, "fTreeView is null");
  Objects.requireNonNull(fBlocksView, "fBlocksView is null");
  Objects.requireNonNull(fGroupsView, "fGroupsView is null");
  Objects.requireNonNull(fPropertiesComponent, "fPropertiesComponent is null");
  Objects.requireNonNull(statusScrollPane, "statusScrollPane is null");

  control = new CControl(frame);
  control.setGroupBehavior(CGroupBehavior.TOPMOST);

  // Disable keyboard shortcuts to avoid collisions.
  control.putProperty(CControl.KEY_GOTO_NORMALIZED, null);
  control.putProperty(CControl.KEY_GOTO_EXTERNALIZED, null);
  control.putProperty(CControl.KEY_GOTO_MAXIMIZED, null);
  control.putProperty(CControl.KEY_MAXIMIZE_CHANGE, null);

  ResourceBundleUtil bundleTreeView = ResourceBundleUtil.getBundle(I18nPlantOverview.TREEVIEW_PATH);
  CGrid grid = new CGrid(control);
  courseTabPane = new CStack(COURSE_TAB_PANE_ID);
  tabPanes.put(COURSE_TAB_PANE_ID, courseTabPane);
  DefaultSingleCDockable vehiclesDockable
      = createDockable(VEHICLES_DOCKABLE_ID,
                       vehiclesPanel.getAccessibleContext().getAccessibleName(),
                       vehiclesPanel,
                       false);
  treeTabPane = new CStack(TREE_TAB_PANE_ID);
  tabPanes.put(TREE_TAB_PANE_ID, treeTabPane);
  DefaultSingleCDockable treeViewDock
      = createDockable(COMPONENTS_ID,
                       bundleTreeView.getString("dockingManager.panel_components.title"),
                       (JComponent) fTreeView,
                       false);
  DefaultSingleCDockable treeBlocks
      = createDockable(BLOCKS_ID,
                       bundleTreeView.getString("dockingManager.panel_blocks.title"),
                       (JComponent) fBlocksView,
                       false);
  DefaultSingleCDockable treeGroups
      = createDockable(GROUPS_ID,
                       bundleTreeView.getString("dockingManager.panel_groups.title"),
                       (JComponent) fGroupsView,
                       false);

  grid.add(0, 0, 250, 400, treeTabPane);
  grid.add(0, 400, 250, 400,
           createDockable(PROPERTIES_ID,
                          ResourceBundleUtil.getBundle(I18nPlantOverview.PROPERTIES_PATH)
                              .getString("dockingManager.panel_properties.title"),
                          fPropertiesComponent,
                          false));
  grid.add(0, 800, 250, 200,
           createDockable(STATUS_ID,
                          ResourceBundleUtil.getBundle(I18nPlantOverview.STATUS_PATH)
                              .getString("dockingManager.panel_status.title"),
                          statusScrollPane,
                          false));
  grid.add(250, 0, 150, 500, vehiclesDockable);
  grid.add(400, 0, 1000, 500, courseTabPane);

  control.getContentArea().deploy(grid);

  // init tab panes
  addTabTo(treeViewDock, TREE_TAB_PANE_ID, 0);
  addTabTo(treeBlocks, TREE_TAB_PANE_ID, 1);
  addTabTo(treeGroups, TREE_TAB_PANE_ID, 2);
  treeTabPane.getStation().setFrontDockable(treeViewDock.intern());
}
 
Example #25
Source File: DockableTitleComparator.java    From openAGV with Apache License 2.0 4 votes vote down vote up
@Override
public int compare(DefaultSingleCDockable o1, DefaultSingleCDockable o2) {
  return o1.getTitleText().compareTo(o2.getTitleText());
}
 
Example #26
Source File: OpenTCSView.java    From openAGV with Apache License 2.0 4 votes vote down vote up
public DrawingViewClosingListener(DefaultSingleCDockable newDockable) {
  this.newDockable = newDockable;
}
 
Example #27
Source File: OpenTCSView.java    From openAGV with Apache License 2.0 4 votes vote down vote up
/**
 * Adds a new drawing view to the tabbed wrappingPanel.
 *
 * @return The newly created Dockable.
 */
public DefaultSingleCDockable addDrawingView() {
  DrawingViewScrollPane newScrollPane
      = drawingViewFactory.createDrawingView(fModelManager.getModel(),
                                             toolBarManager.getSelectionToolButton(),
                                             toolBarManager.getDragToolButton(),
                                             toolBarManager.getButtonCreateLink(),
                                             toolBarManager.getButtonCreatePath());

  int drawingViewIndex = viewManager.getNextDrawingViewIndex();

  String title = bundle.getString("openTcsView.panel_operatingDrawingView.title") + " " + drawingViewIndex;
  DefaultSingleCDockable newDockable
      = dockingManager.createDockable("drivingCourse" + drawingViewIndex,
                                      title,
                                      newScrollPane,
                                      true);
  viewManager.addDrawingView(newDockable, newScrollPane);

  // Add to group pop ups
  if (drawingViewIndex > 0) { //don't add to modelling view
    ModelComponent groups = fModelManager.getModel().getMainFolder(SystemModel.FolderKey.GROUPS);

    for (Object o : groups.getChildComponents()) {
      if (o instanceof GroupModel) {
        GroupModel gf = (GroupModel) o;
        gf.setDrawingViewVisible(title, true);
      }
    }
  }

  int lastIndex = Math.max(0, drawingViewIndex - 1);
  dockingManager.addTabTo(newDockable, DockingManager.COURSE_TAB_PANE_ID, lastIndex);

  newDockable.addVetoClosingListener(new DrawingViewClosingListener(newDockable));
  newDockable.addFocusListener(drawingViewFocusHandler);

  newScrollPane.getDrawingView().dispatchEvent(new FocusEvent(this, FocusEvent.FOCUS_GAINED));
  firePropertyChange(OpenTCSDrawingView.FOCUS_GAINED, null, newDockable);

  return newDockable;
}
 
Example #28
Source File: ViewManager.java    From openAGV with Apache License 2.0 4 votes vote down vote up
public Map<DefaultSingleCDockable, OrderSequencesContainerPanel> getOrderSequenceMap() {
  return orderSequenceViews;
}
 
Example #29
Source File: ViewManager.java    From openAGV with Apache License 2.0 4 votes vote down vote up
public Map<DefaultSingleCDockable, TransportOrdersContainerPanel> getTransportOrderMap() {
  return transportOrderViews;
}
 
Example #30
Source File: ViewManager.java    From openAGV with Apache License 2.0 3 votes vote down vote up
/**
 * Toggles the visibility of the group members for a specific
 * <code>OpenTCSDrawingView</code>.
 *
 * @param title The title of the drawing view.
 * @param sf The group folder containing the elements to hide.
 * @param visible Visible or not.
 */
public void setGroupVisibilityInDrawingView(String title, GroupModel sf, boolean visible) {
  for (DefaultSingleCDockable dock : drawingViewMap.keySet()) {
    if (dock.getTitleText().equals(title)) {
      drawingViewMap.get(dock).getDrawingView().setGroupVisible(sf.getChildComponents(), visible);
    }
  }
}