use of com.ramussoft.gui.common.TabView in project ramus by Vitaliy-Yakovchuk.
the class FilePlugin method saveToFile.
private void saveToFile(File f) throws IOException {
framework.propertyChanged(BEFORE_FILE_SAVE, f);
OutputStream out = engine2.getOutputStream("/user/gui/session.binary");
ObjectOutputStream oos = new ObjectOutputStream(out);
try {
List<TabView> views = framework.getTabViews();
List<com.ramussoft.gui.common.event.ActionEvent> session = new ArrayList<com.ramussoft.gui.common.event.ActionEvent>();
for (View view : views) {
com.ramussoft.gui.common.event.ActionEvent event = view.getOpenAction();
session.add(event);
}
oos.writeObject(session);
} catch (Exception e) {
e.printStackTrace();
} finally {
oos.close();
}
engine.saveToFile(f);
Runner.saveFileToHistory(f);
setChangedFalse();
}
use of com.ramussoft.gui.common.TabView in project ramus by Vitaliy-Yakovchuk.
the class GUIPluginFactory method addActions.
private void addActions(String id, final View view, final DefaultCDockable dockable, Action[] actions) {
for (final Action action : actions) if (action == null) {
dockable.addSeparator();
} else {
ImageIcon icon = (ImageIcon) action.getValue(Action.SMALL_ICON);
if (icon == null) {
icon = new ImageIcon(getClass().getResource("/com/ramussoft/gui/icon.png"));
}
final String command = (String) action.getValue(Action.ACTION_COMMAND_KEY);
String text = null;
if (view instanceof TabView) {
text = ((TabView) view).getString(command);
}
if (text == null)
text = findPluginForViewId(id).getString(command);
if (text == null) {
StringGetter getter = (StringGetter) action.getValue(StringGetter.ACTION_STRING_GETTER);
if (getter != null)
text = getter.getString(command);
}
final CDecorateableAction button;
if (action.getValue(Action.SELECTED_KEY) == null) {
final PopupTrigger trigger = (PopupTrigger) action.getValue(POPUP_MENU);
if (trigger == null)
button = new CButton(text, icon) {
@Override
protected void action() {
java.awt.event.ActionEvent e = new java.awt.event.ActionEvent(view, 0, command);
action.actionPerformed(e);
}
};
else {
button = new CPanelPopup() {
@Override
public void openPopup(PanelPopupWindow window) {
super.openPopup(window);
}
@Override
protected void openDialog(JComponent item, Orientation orientation) {
JPanel menu = (JPanel) getContent();
menu.removeAll();
for (Action action : trigger.getPopupActions()) menu.add(new JButton(action));
menu.revalidate();
menu.repaint();
super.openDialog(item, orientation);
}
};
((CPanelPopup) button).setContent(new JPanel(new GridLayout(0, 1, 0, 0)));
button.setText(text);
button.setIcon(icon);
}
} else {
button = new CCheckBox(text, icon) {
@Override
protected void changed() {
java.awt.event.ActionEvent e = new java.awt.event.ActionEvent(view, 0, command);
action.putValue(Action.SELECTED_KEY, isSelected());
action.actionPerformed(e);
}
};
action.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (Action.SELECTED_KEY.equals(evt.getPropertyName())) {
((CCheckBox) button).setSelected((Boolean) evt.getNewValue());
}
}
});
((CCheckBox) button).setSelected((Boolean) action.getValue(Action.SELECTED_KEY));
}
String tooltip = (String) action.getValue(Action.LONG_DESCRIPTION);
if (tooltip == null)
tooltip = (String) action.getValue(Action.SHORT_DESCRIPTION);
if (tooltip == null)
tooltip = text;
if (tooltip != null)
button.setTooltip(tooltip);
KeyStroke stroke = (KeyStroke) action.getValue(Action.ACCELERATOR_KEY);
if (stroke != null)
button.setAccelerator(stroke);
actionButtons.put(action, button);
button.setEnabled(action.isEnabled());
dockable.addAction(button);
action.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("enabled")) {
button.setEnabled((Boolean) evt.getNewValue());
}
}
});
}
}
use of com.ramussoft.gui.common.TabView in project ramus by Vitaliy-Yakovchuk.
the class GUIPluginFactory method loadCurrentWorkspase.
private void loadCurrentWorkspase() {
control.load(this.currentWorkspace);
if (this.currentWorkspace != null) {
View view = workspaceViews.get(this.currentWorkspace);
if (view != null) {
Enumeration<TabView> enumeration = tabDockables.keys();
while (enumeration.hasMoreElements()) {
TabView tabView = enumeration.nextElement();
if (view == tabView) {
TabDockable dockable = tabDockables.get(view);
dockable.intern().getController().setFocusedDockable(dockable.intern(), false);
}
}
}
}
}
use of com.ramussoft.gui.common.TabView in project ramus by Vitaliy-Yakovchuk.
the class GUIPluginFactory method tabCreated.
protected void tabCreated(TabbedEvent event) {
TabView view = event.getTabableView();
TabDockable dockable = tabDockables.get(event.getTabableView());
if (dockable != null) {
dockable.intern().getController().setFocusedDockable(dockable.intern(), false);
return;
}
String id = event.getTabViewId();
CWorkingArea area = getWorkingArea(id);
if (!area.isVisible())
area.setVisible(true);
dockable = new TabDockable(factories.get(id), view.createComponent());
tabDockables.put(view, dockable);
dockable.setRemoveOnClose(true);
initActions(id, view, dockable);
dockable.setLocation(CLocation.working(area).rectangle(0, 0, 1, 1));
dockable.setTitleText(view.getTitle());
dockable.setCloseable(true);
area.add(dockable);
dockable.setVisible(true);
dockable.intern().getController().setFocusedDockable(dockable.intern(), false);
}
use of com.ramussoft.gui.common.TabView in project ramus by Vitaliy-Yakovchuk.
the class SimleGUIPluginFactory method tabCreated.
protected void tabCreated(TabbedEvent event) {
TabView view = event.getTabableView();
TabFrame dockable = tabDockables.get(event.getTabableView());
if (dockable != null) {
control.setActive(dockable);
return;
}
String id = event.getTabViewId();
Area area = getWorkingArea(id);
if (!area.isVisible())
area.setVisible(true);
dockable = new TabFrame(control, area, view);
tabDockables.put(view, dockable);
dockable.setRemoveOnClose(true);
initActions(id, view, dockable);
// dockable.setTitleText(view.getTitle());
dockable.setCloseable(true);
dockable.setVisible(true);
}
Aggregations