use of com.ramussoft.gui.common.event.ActionEvent in project ramus by Vitaliy-Yakovchuk.
the class GUIPluginFactory method initContent.
@SuppressWarnings("deprecation")
private void initContent() {
control = new CControl(plugableFrame, false);
// control.setTheme(control.getThemes().getFactory(2).create());
control.addControlListener(new CControlListener() {
@Override
public void added(CControl control, CDockable dockable) {
}
@Override
public void closed(CControl control, CDockable dockable) {
Boolean b = recHash.get(Thread.currentThread());
if (b != null)
return;
recHash.put(Thread.currentThread(), true);
List<TabView> list = new ArrayList<TabView>();
for (Entry<TabView, TabDockable> e : tabDockables.entrySet()) {
if (e.getValue().equals(dockable)) {
TabView view = e.getKey();
list.add(view);
}
}
for (TabView view : list) view.close();
recHash.remove(Thread.currentThread());
}
@Override
public void opened(CControl control, CDockable dockable) {
}
@Override
public void removed(CControl control, CDockable dockable) {
}
});
control.addFocusListener(new CFocusListener() {
@Override
public void focusGained(CDockable dockable) {
List<View> list = new ArrayList<View>();
for (Entry<TabView, TabDockable> e : tabDockables.entrySet()) {
if (e.getValue().equals(dockable)) {
TabView view = e.getKey();
list.add(view);
}
}
if (dockable instanceof DefaultSingleCDockable) {
list.add(findUniqueView(((DefaultSingleCDockable) dockable).getUniqueId()));
}
for (View view : list) {
lastActiveView = view;
view.focusGained();
plugableFrame.setViewActions(view.getGlobalActions());
if ((!(view instanceof UniqueView)) && (view instanceof TabView)) {
if (currentWorkspace != null)
workspaceViews.put(currentWorkspace, view);
}
}
}
@Override
public void focusLost(CDockable dockable) {
List<View> list = new ArrayList<View>();
for (Entry<TabView, TabDockable> e : tabDockables.entrySet()) {
if (e.getValue().equals(dockable)) {
TabView view = e.getKey();
list.add(view);
}
}
if (dockable instanceof DefaultSingleCDockable) {
list.add(findUniqueView(((DefaultSingleCDockable) dockable).getUniqueId()));
}
for (View view : list) view.focusLost();
plugableFrame.setViewActions(new String[] {});
}
});
// control.setTheme(ThemeMap.KEY_ECLIPSE_THEME);
contentArea = control.getContentArea();
plugableFrame.add(contentArea, BorderLayout.CENTER);
for (UniqueView view : uniqueViews) {
String id = view.getId();
final DefaultSingleCDockable dockable = new DefaultSingleCDockable(id, findPluginForViewId(id).getString(id), view.createComponent());
dockable.setCloseable(true);
initActions(view.getId(), view, dockable);
control.addDockable(dockable);
uniqueDockables.add(dockable);
framework.addActionListener(id, new ActionListener() {
@Override
public void onAction(ActionEvent event) {
dockable.setVisible(true);
}
});
if (currentWorkspace.equals(view.getDefaultWorkspace()))
dockable.setVisible(true);
}
for (TabbedView view : tabbedViews) {
String id = view.getId();
if (getWorkingArea(id) != null)
continue;
CWorkingArea area = control.createWorkingArea(id);
uniqueWorkingAreas.add(area);
// area.setTitleShown(false);
// if (currentWorkspace.equals(view.getDefaultWorkspace()))
area.setVisible(true);
TabbedFactory factory = new TabbedFactory();
factories.put(id, factory);
control.addMultipleDockableFactory(id, factory);
// dockable.setWorkingArea(area);
// dockable1.setWorkingArea(area);
// control.add(dockable1);
// control.add(dockable);
// dockable.setLocation(CLocation.base().)
}
framework.setMainFrame(plugableFrame);
}
use of com.ramussoft.gui.common.event.ActionEvent in project ramus by Vitaliy-Yakovchuk.
the class Runner method openInNewWindows.
@SuppressWarnings("unchecked")
public JFrame openInNewWindows(final Engine engine, final AccessRules rules, final File file, final boolean recovered) {
List<GUIPlugin> list = new ArrayList<GUIPlugin>();
FilePlugin filePlugin = new FilePlugin((FileIEngineImpl) engine.getDeligate(), engine, rules, file, this);
list.add(filePlugin);
list.add(new UndoRedoPlugin(engine));
initAdditionalGUIPlugins(list, engine, rules);
final AbstractGUIPluginFactory factory = createGUIPluginFactory(engine, rules, list);
final JFrame frame = factory.getMainFrame();
engine.setPluginProperty(CORE, "MainFrame", frame);
String title = getApplicationTitle();
if (file != null)
title += " - " + file.getName();
frame.setTitle(title);
factory.getFramework().addCloseMainFrameListener(new CloseMainFrameAdapter() {
@Override
public void afterClosed() {
List<JFrame> list = (List<JFrame>) engine.getPluginProperty(CORE, "AdditionalWindows");
if (list != null) {
JFrame[] frames = list.toArray(new JFrame[list.size()]);
for (JFrame frame : frames) {
frame.setVisible(false);
frame.dispose();
}
}
FileIEngineImpl impl = (FileIEngineImpl) engine.getDeligate();
try {
impl.getTemplate().getConnection().close();
if (engine instanceof Journaled)
((Journaled) engine).close();
impl.close();
impl.clear();
} catch (Exception e1) {
e1.printStackTrace();
}
}
});
Object changed = engine.getPluginProperty(CORE, "Changed");
if (changed != null)
filePlugin.changed();
InputStream is = engine.getInputStream("/user/gui/session.binary");
if (is != null) {
try {
ObjectInputStream ois = new ObjectInputStream(is);
try {
final List<ActionEvent> session = (List<ActionEvent>) ois.readObject();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
for (ActionEvent e : session) if (e != null)
factory.getFramework().propertyChanged(e);
}
});
} catch (Exception e) {
e.printStackTrace();
} finally {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
beforeMainFrameShow(frame);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
frame.setVisible(true);
if (recovered) {
factory.getFramework().propertyChanged("FileRecovered");
} else
factory.getFramework().propertyChanged("FileOpened", file);
postShowVisibaleMainFrame(engine, factory.getFramework());
}
});
return frame;
}
use of com.ramussoft.gui.common.event.ActionEvent in project ramus by Vitaliy-Yakovchuk.
the class ReportViewPlugin method addOpenReportEditorListener.
private void addOpenReportEditorListener() {
framework.addActionListener(OPEN_SCRIPT_REPORT, new ActionListener() {
@Override
public void onAction(final ActionEvent event) {
if (framework.openView(event))
return;
final Data data = new Data();
data.element = (Element) event.getValue();
data.attributeListener = new ElementAttributeListener() {
@Override
public void attributeChanged(AttributeEvent event) {
Object value = event.getNewValue();
if ((value instanceof String) && (event.getElement().equals(data.element))) {
ViewTitleEvent e = new ViewTitleEvent(data.view, value.toString());
data.view.titleChanged(e);
}
}
};
data.elementListener = new ElementAdapter() {
@Override
public void elementDeleted(ElementEvent event) {
if (event.getOldElement().equals(data.element)) {
data.view.close();
}
}
};
engine.addElementListener(ReportPlugin.getReportsQualifier(engine), data.elementListener);
engine.addElementAttributeListener(ReportPlugin.getReportsQualifier(engine), data.attributeListener);
String type = (String) engine.getAttribute(data.element, ReportPlugin.getReportTypeAttribute(engine));
if (ReportPlugin.TYPE_JSSP.equals(type))
data.view = new ScriptReportEditorView(framework, data.element) {
@Override
public void close() {
super.close();
engine.removeElementListener(ReportPlugin.getReportsQualifier(engine), data.elementListener);
engine.removeElementAttributeListener(ReportPlugin.getReportsQualifier(engine), data.attributeListener);
TabbedEvent tEvent = new TabbedEvent("TabbedTableView", this);
tabRemoved(tEvent);
}
@Override
public String getTitle() {
return data.element.getName();
}
};
else if (ReportPlugin.TYPE_JSSP_DOC_BOOK.equals(type))
data.view = new DocBookScriptReportEditorView(framework, data.element) {
@Override
public void close() {
super.close();
engine.removeElementListener(ReportPlugin.getReportsQualifier(engine), data.elementListener);
engine.removeElementAttributeListener(ReportPlugin.getReportsQualifier(engine), data.attributeListener);
TabbedEvent tEvent = new TabbedEvent("TabbedTableView", this);
tabRemoved(tEvent);
}
@Override
public String getTitle() {
return data.element.getName();
}
};
else
data.view = new XMLReportEditorView(framework, data.element) {
@Override
public void close() {
super.close();
engine.removeElementListener(ReportPlugin.getReportsQualifier(engine), data.elementListener);
engine.removeElementAttributeListener(ReportPlugin.getReportsQualifier(engine), data.attributeListener);
TabbedEvent tEvent = new TabbedEvent("TabbedTableView", this);
tabRemoved(tEvent);
}
@Override
public String getTitle() {
return data.element.getName();
}
};
TabbedEvent tEvent = new TabbedEvent(REPORTS_TAB_VIEW, data.view);
tabCreated(tEvent);
}
});
}
use of com.ramussoft.gui.common.event.ActionEvent in project ramus by Vitaliy-Yakovchuk.
the class ChartGUIPlugin method setFramework.
@Override
public void setFramework(GUIFramework aFramework) {
super.setFramework(aFramework);
framework.addActionListener(OPEN_CHART, new ActionListener() {
@Override
public void onAction(ActionEvent event) {
if (framework.openView(event))
return;
Element element = (Element) event.getValue();
ChartView view = new ChartView(framework, element) {
@Override
public void close() {
super.close();
TabbedEvent tEvent = new TabbedEvent("TabbedTableView", this);
tabRemoved(tEvent);
}
};
TabbedEvent tEvent = new TabbedEvent(TabbedTableView.MAIN_TABBED_VIEW, view);
tabCreated(tEvent);
}
});
framework.addActionListener(OPEN_CHART_SET, new ActionListener() {
@Override
public void onAction(ActionEvent event) {
if (framework.openView(event))
return;
Element element = (Element) event.getValue();
ChartSetView view = new ChartSetView(framework, element) {
@Override
public void close() {
super.close();
TabbedEvent tEvent = new TabbedEvent("TabbedTableView", this);
tabRemoved(tEvent);
}
};
TabbedEvent tEvent = new TabbedEvent(TabbedTableView.MAIN_TABBED_VIEW, view);
tabCreated(tEvent);
}
});
}
use of com.ramussoft.gui.common.event.ActionEvent in project ramus by Vitaliy-Yakovchuk.
the class ElistPlugin method setFramework.
@Override
public void setFramework(final GUIFramework framework) {
super.setFramework(framework);
framework.addActionListener(OPEN_ELEMENT_LIST, new ActionListener() {
@Override
public void onAction(final ActionEvent event) {
if (framework.openView(event))
return;
Attribute attribute = (Attribute) event.getValue();
ElistTabView elistTabView = new ElistTabView(framework, attribute) {
@Override
public void close() {
super.close();
TabbedEvent tEvent = new TabbedEvent("TabbedTableView", this);
tabRemoved(tEvent);
}
};
TabbedEvent tEvent = new TabbedEvent(TabbedTableView.MAIN_TABBED_VIEW, elistTabView);
tabCreated(tEvent);
}
});
framework.addActionListener(OPEN_ELEMENT_LIST_IN_TABLE, new ActionListener() {
@Override
public void onAction(final ActionEvent event) {
if (framework.openView(event))
return;
Attribute attribute = (Attribute) event.getValue();
ElistTableTabView elistTabView = new ElistTableTabView(framework, attribute) {
@Override
public void close() {
super.close();
TabbedEvent tEvent = new TabbedEvent("TabbedTableView", this);
tabRemoved(tEvent);
}
};
TabbedEvent tEvent = new TabbedEvent(TabbedTableView.MAIN_TABBED_VIEW, elistTabView);
tabCreated(tEvent);
}
});
}
Aggregations