use of com.igormaznitsa.sciareto.ui.tree.NodeProject in project netbeans-mmd-plugin by raydac.
the class MainFrame method saveState.
private void saveState() {
try {
final List<File> files = new ArrayList<>();
for (final NodeFileOrFolder p : this.explorerTree.getCurrentGroup()) {
final File f = ((NodeProject) p).getFolder();
if (f.isDirectory()) {
files.add(f);
}
}
FileHistoryManager.getInstance().saveActiveProjects(files.toArray(new File[files.size()]));
files.clear();
for (final TabTitle p : this.tabPane) {
final File f = p.getAssociatedFile();
if (f != null && f.isFile()) {
files.add(f);
}
}
FileHistoryManager.getInstance().saveActiveFiles(files.toArray(new File[files.size()]));
} catch (IOException ex) {
// NOI18N
LOGGER.error("Can't save state", ex);
}
}
use of com.igormaznitsa.sciareto.ui.tree.NodeProject in project netbeans-mmd-plugin by raydac.
the class MMDEditor method getProjectFolder.
@Nullable
private File getProjectFolder() {
File result = null;
final File associatedFile = this.title.getAssociatedFile();
if (associatedFile != null) {
final NodeProject project = context.findProjectForFile(associatedFile);
result = project == null ? null : project.getFolder();
}
return result;
}
use of com.igormaznitsa.sciareto.ui.tree.NodeProject in project netbeans-mmd-plugin by raydac.
the class TabTitle method saveAs.
public boolean saveAs() throws IOException {
boolean result = false;
if (this.parent.saveDocumentAs()) {
result = true;
final NodeProject project = this.context.findProjectForFile(this.associatedFile);
if (project != null) {
project.getGroup().refreshProjectFolder(project, PrefUtils.isShowHiddenFilesAndFolders());
this.context.focusInTree(this);
}
}
return result;
}
use of com.igormaznitsa.sciareto.ui.tree.NodeProject in project netbeans-mmd-plugin by raydac.
the class NodeListRenderer method getListCellRendererComponent.
@Override
@Nonnull
public Component getListCellRendererComponent(@Nonnull final JList<?> list, @Nonnull final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
final NodeFileOrFolder node = (NodeFileOrFolder) value;
final String ext = FilenameUtils.getExtension(node.toString()).toLowerCase(Locale.ENGLISH);
if (!isSelected && COLOR_ROW_EVEN != null && COLOR_ROW_ODD != null) {
if (index % 2 == 0) {
this.setBackground(COLOR_ROW_EVEN);
} else {
this.setBackground(COLOR_ROW_ODD);
}
}
if (node instanceof NodeProject || !node.isLeaf()) {
this.setIcon(TreeCellRenderer.DEFAULT_FOLDER_CLOSED);
} else if (ext.equals("mmd")) {
// NOI18N
this.setIcon(Icons.DOCUMENT.getIcon());
} else if (PictureViewer.SUPPORTED_FORMATS.contains(ext)) {
this.setIcon(TreeCellRenderer.ICON_IMAGE);
} else {
this.setIcon(TreeCellRenderer.DEFAULT_FILE);
}
this.setText(makeTextForNode(node));
return this;
}
Aggregations