use of org.openide.windows.CloneableTopComponent in project netbeans-rcp-lite by outersky.
the class MultiViewPeer method updateName.
// from CloneableEditor.Pane
public void updateName() {
// is called before setMultiViewDescriptions() need to check for null.
if (model != null) {
for (MultiViewDescription mvd : model.getDescriptions()) {
if (mvd instanceof ContextAwareDescription && ((ContextAwareDescription) mvd).isSplitDescription())
// #240371 - don't update name from spit elements
continue;
MultiViewElement el = model.getElementForDescription(mvd, MultiViewCloneableTopComponent.isSourceView(mvd));
if (el == null) {
continue;
}
if (el.getVisualRepresentation() instanceof Pane) {
Pane pane = (Pane) el.getVisualRepresentation();
pane.updateName();
final CloneableTopComponent tc = pane.getComponent();
peer.setDisplayName(tc.getDisplayName());
peer.setIcon(tc.getIcon());
if (!Arrays.asList(tc.getPropertyChangeListeners()).contains(propListener)) {
tc.addPropertyChangeListener(propListener);
}
}
}
}
}
use of org.openide.windows.CloneableTopComponent in project netbeans-rcp-lite by outersky.
the class MultiViewPeer method addPropertyChangeListeners.
private void addPropertyChangeListeners() {
if (null != model) {
for (MultiViewDescription mvd : model.getDescriptions()) {
if (mvd instanceof ContextAwareDescription && ((ContextAwareDescription) mvd).isSplitDescription())
// #240371 - don't update name from spit elements
continue;
MultiViewElement el = model.getElementForDescription(mvd, false);
if (el == null) {
continue;
}
if (el.getVisualRepresentation() instanceof Pane) {
Pane pane = (Pane) el.getVisualRepresentation();
final CloneableTopComponent tc = pane.getComponent();
if (!Arrays.asList(tc.getPropertyChangeListeners()).contains(propListener)) {
tc.addPropertyChangeListener(propListener);
}
}
}
}
}
use of org.openide.windows.CloneableTopComponent in project netbeans-rcp-lite by outersky.
the class MultiViewCloneableEditor method canCloseElement.
@Messages({ "# {0} - file name", "MSG_SaveModified=File {0} is modified. Save?", "MSG_SaveModified_no_name=File is modified. Save?" })
@Override
public CloseOperationState canCloseElement() {
final CloneableEditorSupport sup = getLookup().lookup(CloneableEditorSupport.class);
Enumeration<CloneableTopComponent> en = getReference().getComponents();
if (en.hasMoreElements()) {
en.nextElement();
if (en.hasMoreElements()) {
// at least two is OK
return CloseOperationState.STATE_OK;
}
}
Savable sav = getLookup().lookup(Savable.class);
if (sav != null) {
AbstractAction save = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
try {
sup.saveDocument();
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}
};
try {
if (sav.getClass().getMethod("toString").getDeclaringClass() != Object.class) {
save.putValue(Action.LONG_DESCRIPTION, Bundle.MSG_SaveModified(sav));
} else {
Logger.getLogger(MultiViewCloneableEditor.class.getName()).log(Level.WARNING, "Need to override toString() to contain the file name in o.n.api.action.Savable {0} with lookup {1}", new Object[] { sav.getClass(), getLookup().lookupAll(Object.class) });
Node n = getLookup().lookup(Node.class);
if (n != null) {
// #201696: compatibility fallback.
save.putValue(Action.LONG_DESCRIPTION, Bundle.MSG_SaveModified(n.getDisplayName()));
} else {
save.putValue(Action.LONG_DESCRIPTION, Bundle.MSG_SaveModified_no_name());
}
}
} catch (NoSuchMethodException x) {
assert false : x;
}
return MultiViewFactory.createUnsafeCloseState("editor", save, null);
}
return CloseOperationState.STATE_OK;
}
use of org.openide.windows.CloneableTopComponent in project constellation by constellation-app.
the class RecentFiles method removeFile.
/**
* Removes file represented by given TopComponent from the list
*/
private static void removeFile(final TopComponent tc) {
historyProbablyValid = false;
if (tc instanceof CloneableTopComponent) {
final String path = obtainPath(tc);
if (path != null) {
synchronized (HISTORY_LOCK) {
final HistoryItem hItem = findHistoryItem(path);
if (hItem != null) {
HISTORY.remove(hItem);
}
store();
}
}
}
}
Aggregations