use of com.ramussoft.pb.idef.frames.IDEFPanel in project ramus by Vitaliy-Yakovchuk.
the class IDEF0TabView method createPanel.
private void createPanel() {
panel = new IDEFPanel(frame, dataPlugin, framework, rules, this) {
@Override
protected void openTab(Function function) {
long id = -1;
if (!dataPlugin.getBaseFunction().equals(function))
id = function.getElement().getId();
OpenDiagram openDiagram = new OpenDiagram(dataPlugin.getBaseFunctionQualifier(), id);
framework.propertyChanged(IDEF0ViewPlugin.OPEN_DIAGRAM, openDiagram);
}
@Override
protected void setActiveObject(Object activeObject) {
super.setActiveObject(activeObject);
if (activeObject instanceof VisualPanel)
activaPanel = (VisualPanel) activeObject;
if ((Boolean) handAction.getValue(AbstractAction.SELECTED_KEY)) {
if (activeObject instanceof VisualPanel) {
panel.getMovingArea().startUserTransaction();
VisualPanel vpanel = (VisualPanel) activeObject;
visualCopy.copyTo(vpanel);
panel.getMovingArea().commitUserTransaction();
}
} else {
if (activeObject instanceof VisualPanel) {
handAction.setEnabled(true);
} else
handAction.setEnabled(false);
}
}
};
Function function = null;
if (functionId >= 0) {
function = (Function) dataPlugin.findRowByGlobalId(functionId);
}
if (function == null)
function = dataPlugin.getBaseFunction();
panel.getMovingArea().setActiveFunction(function);
panel.getMovingArea().addActiveFunctionListener(new ActiveFunctionListener() {
@Override
public void activeFunctionChanged(ActiveFunctionEvent event) {
refreshTitle();
framework.propertyChanged(ACTIVE_DIAGRAM, getOpenAction());
}
});
frame.getActiveZoom().doZoom(panel);
basePanel.add(panel, BorderLayout.CENTER);
}
use of com.ramussoft.pb.idef.frames.IDEFPanel in project ramus by Vitaliy-Yakovchuk.
the class MainFrame method createToolBars.
protected void createToolBars() {
final Object[] editBar = new Object[] { findAction(CUT), findAction(COPY), findAction(PASTE), null, findAction(ADD), findAction(INSERT), findAction(ADD_CHILD), findAction(LEVEL_UP), findAction(LEVEL_DOWN), findAction(EDIT), findAction(REMOVE), findAction(SELECT_CLEAN) };
final Action[] idef0Bar = new Action[] { findAction(CURSOR_TOOL), findAction(FUNCTION_TOOL), findAction(ARROW_TOOL), findAction(TILDA_TOOL), findAction(TEXT_TOOL), findAction(DFDS_ROLE_TOOL), findAction(EXTERNAL_REFERENCE_TOOL), findAction(DATA_STORE_TOOL), findAction(IDEF0_NET) };
editToolBar = createToolBar(editBar);
idef0StateToolBar = new JToolBar();
idef0StateToolBar.setRollover(true);
idef0StateToolBar.setFloatable(true);
for (final Action action : idef0Bar) {
final JToggleButton button = new JToggleButton(action);
button.setText(null);
idef0StateToolBar.add(button);
if (action != idef0Bar[idef0Bar.length - 1]) {
idef0StateGroup.add(button);
action.putValue(BUTTON_GROUP, idef0StateGroup);
action.putValue(BUTTON_GROUP_ADDED, Boolean.TRUE);
if ((action == idef0Bar[idef0Bar.length - 2]) || (action == idef0Bar[idef0Bar.length - 3]))
dfdButtons.add(button);
if (action == idef0Bar[idef0Bar.length - 4])
dfdsButtons.add(button);
}
button.setFocusable(false);
action.putValue(Action.SELECTED_KEY, Boolean.FALSE);
}
findAction(CURSOR_TOOL).putValue(Action.SELECTED_KEY, Boolean.TRUE);
idef0StateToolBar.add(findAction(GO_TO_PARENT));
idef0StateToolBar.add(findAction(GO_TO_CHILD));
addMoreIDEF0Commants();
final JPanel zoom = new JPanel();
zoom.setLayout(new BorderLayout());
zoomComboBox.addItem(IDEFPanel.createZoom(0.25));
zoomComboBox.addItem(IDEFPanel.createZoom(0.5));
zoomComboBox.addItem(IDEFPanel.createZoom(1.0));
zoomComboBox.addItem(IDEFPanel.createZoom(1.5));
zoomComboBox.addItem(IDEFPanel.createZoom(2.0));
zoomComboBox.addItem(IDEFPanel.createZoom(3.0));
zoomComboBox.addItem(IDEFPanel.createZoom(IDEFPanel.FIT_ALL));
zoomComboBox.addItem(IDEFPanel.createZoom(IDEFPanel.FIT_WIDTH));
zoomComboBox.addItem(IDEFPanel.createZoom(IDEFPanel.FIT_HEIGHT));
zoomComboBox.setEditable(true);
zoom.add(zoomComboBox, BorderLayout.CENTER);
zoomComboBox.setEnabled(false);
final JPanel zLabel = new JPanel();
zLabel.setLayout(new BorderLayout());
final JPanel tmpPanel = new JPanel();
tmpPanel.setLayout(new FlowLayout());
zLabel.add(tmpPanel, BorderLayout.CENTER);
zLabel.add(new JLabel(ResourceLoader.getString("zoom:")), BorderLayout.WEST);
zoom.add(zLabel, BorderLayout.WEST);
zoomComboBox.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
Object item = zoomComboBox.getSelectedItem();
if (item instanceof String) {
String s = (String) item;
StringBuilder sb = new StringBuilder();
for (char c : s.toCharArray()) if (Character.isDigit(c) || c == '.')
sb.append(c);
else if (c == ',')
sb.append('.');
double zoom2 = Double.parseDouble(sb.toString()) / 100d;
if (zoom2 < 0.07 || zoom2 > 20)
return;
item = new Zoom(zoom2);
zoomComboBox.setSelectedItem(item);
}
zoomComboBox.setFocusable(false);
zoomComboBox.setFocusable(true);
final Zoom zoom = (Zoom) item;
if (activeView instanceof IDEFPanel)
zoom.doZoom((IDEFPanel) activeView);
int selectedIndex = zoomComboBox.getSelectedIndex();
Options.setInteger(IDEFPanel.IDEF0_ZOOM, selectedIndex);
if (selectedIndex < 0)
Options.setDouble("IDEF0D_ZOOM_DOUBLE", zoom.getZoom());
}
});
int selectedIndex = Options.getInteger(IDEFPanel.IDEF0_ZOOM, 6);
if (selectedIndex >= 0)
zoomComboBox.setSelectedIndex(selectedIndex);
else
zoomComboBox.setSelectedItem(new Zoom(Options.getDouble("IDEF0D_ZOOM_DOUBLE", 1)));
idef0StateToolBar.addSeparator();
idef0StateToolBar.add(zoom);
desableFocus(editToolBar);
desableFocus(idef0StateToolBar);
// pane.add(ToolBarLayout.north, fileToolBar);
// pane.add(ToolBarLayout.north, idef0StateToolBar);
// pane.add(ToolBarLayout.north, reportToolBar);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
actionPerformed(new ActionEvent(this, 0, CURSOR_TOOL));
}
});
}
Aggregations