Skip to content

Commit 6a9dcdf

Browse files
committed
smoothing out footer handling
1 parent 6de5140 commit 6a9dcdf

File tree

5 files changed

+104
-66
lines changed

5 files changed

+104
-66
lines changed

app/src/processing/app/Base.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,8 @@ protected Editor handleOpen(String path, boolean untitled, EditorState state) {
823823
} catch (Throwable t) {
824824
showBadnessTrace("Terrible News",
825825
"A serious error occurred while " +
826-
"trying to create a new editor window.", t, false);
826+
"trying to create a new editor window.", t,
827+
nextMode == getDefaultMode()); // quit if default
827828
nextMode = getDefaultMode();
828829
return null;
829830
}

app/src/processing/app/Editor.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
import java.awt.BorderLayout;
3232
import java.awt.Component;
33-
import java.awt.Container;
3433
import java.awt.Dimension;
3534
import java.awt.EventQueue;
3635
import java.awt.Frame;
@@ -96,7 +95,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
9695
protected JEditTextArea textarea;
9796
protected EditorStatus status;
9897
protected JSplitPane splitPane;
99-
protected Container consolePanel;
98+
protected EditorFooter footer;
10099
protected EditorConsole console;
101100
// protected EditorLineStatus lineStatus;
102101

@@ -246,15 +245,15 @@ public void paintComponent(Graphics g) {
246245
textarea.setRightClickPopup(new TextAreaPopup());
247246
textarea.setHorizontalOffset(JEditTextArea.leftHandGutter);
248247

249-
consolePanel = createFooter();
248+
footer = createFooter();
250249

251250
upper.add(textarea);
252251

253252
// alternate spot for status, but ugly
254253
// status = new EditorStatus(this);
255254
// upper.add(status);
256255

257-
splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, upper, consolePanel);
256+
splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, upper, footer);
258257

259258
// disable this because it hides the message area, which is essential (issue #745)
260259
splitPane.setOneTouchExpandable(false);
@@ -417,8 +416,11 @@ public void processKeyEvent(KeyEvent evt) {
417416
}
418417

419418

420-
public Container createFooter() {
421-
return new EditorConsole(this);
419+
public EditorFooter createFooter() {
420+
EditorFooter ef = new EditorFooter(this);
421+
console = new EditorConsole(this);
422+
ef.addPanel(Language.text("editor.footer.console"), console);
423+
return ef;
422424

423425
/*
424426
// assemble console panel, consisting of status area and the console itself

app/src/processing/app/EditorFooter.java

Lines changed: 74 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,30 @@ public void addPanel(String name, Component comp) {
101101
}
102102

103103

104+
// public void setPanel(int index) {
105+
// cardLayout.show(cardPanel, tabs.get(index).name);
106+
// }
107+
108+
109+
public void setPanel(Component comp) {
110+
for (Tab tab : tabs) {
111+
if (tab.comp == comp) {
112+
cardLayout.show(cardPanel, tab.name);
113+
}
114+
}
115+
}
116+
117+
118+
public void setNotification(Component comp, boolean note) {
119+
for (Tab tab : tabs) {
120+
if (tab.comp == comp) {
121+
tab.notification = note;
122+
repaint();
123+
}
124+
}
125+
}
126+
127+
104128
public void updateMode() {
105129
Mode mode = editor.getMode();
106130

@@ -127,7 +151,7 @@ public void mousePressed(MouseEvent e) {
127151
for (Tab tab : tabs) {
128152
if (tab.contains(x)) {
129153
//editor.setFooterPanel(tab.index);
130-
cardLayout.show(cardPanel, tab.text);
154+
cardLayout.show(cardPanel, tab.name);
131155
}
132156
}
133157
}
@@ -178,7 +202,7 @@ public void paintComponent(Graphics screen) {
178202
// reset all tab positions
179203
for (Tab tab : tabs) {
180204
tab.textWidth = (int)
181-
font.getStringBounds(tab.text, g2.getFontRenderContext()).getWidth();
205+
font.getStringBounds(tab.name, g2.getFontRenderContext()).getWidth();
182206
}
183207

184208
// now actually draw the tabs
@@ -192,77 +216,81 @@ public void paintComponent(Graphics screen) {
192216

193217
screen.drawImage(offscreen, 0, 0, imageW, imageH, null);
194218
}
195-
}
196219

197220

198-
/**
199-
* @param left starting position from the left
200-
* @param g graphics context, or null if we're not drawing
201-
*/
202-
private void placeTabs(int left, Graphics2D g) {
203-
int x = left;
221+
/**
222+
* @param left starting position from the left
223+
* @param g graphics context, or null if we're not drawing
224+
*/
225+
private void placeTabs(int left, Graphics2D g) {
226+
int x = left;
204227

205-
for (Tab tab : tabs) {
206-
int state = tab.isCurrent() ? SELECTED : UNSELECTED;
207-
tab.left = x;
208-
x += TEXT_MARGIN;
209-
x += tab.textWidth + TEXT_MARGIN;
210-
tab.right = x;
211-
212-
// if drawing and not just placing
213-
if (g != null) {
214-
g.setColor(tabColor[state]);
215-
drawTab(g, tab.left, tab.right, tab.isFirst(), tab.isLast());
216-
217-
int textLeft = tab.left + ((tab.right - tab.left) - tab.textWidth) / 2;
218-
g.setColor(textColor[state]);
219-
int tabHeight = TAB_BOTTOM - TAB_TOP;
220-
int baseline = TAB_TOP + (tabHeight + fontAscent) / 2;
221-
g.drawString(tab.text, textLeft, baseline);
228+
for (Tab tab : tabs) {
229+
int state = tab.isCurrent() ? SELECTED : UNSELECTED;
230+
tab.left = x;
231+
x += TEXT_MARGIN;
232+
x += tab.textWidth + TEXT_MARGIN;
233+
tab.right = x;
234+
235+
// if drawing and not just placing
236+
if (g != null) {
237+
g.setColor(tabColor[state]);
238+
if (tab.notification) {
239+
g.setColor(new Color(192, 0, 0));
240+
}
241+
drawTab(g, tab.left, tab.right, tab.isFirst(), tab.isLast());
242+
243+
int textLeft = tab.left + ((tab.right - tab.left) - tab.textWidth) / 2;
244+
g.setColor(textColor[state]);
245+
int tabHeight = TAB_BOTTOM - TAB_TOP;
246+
int baseline = TAB_TOP + (tabHeight + fontAscent) / 2;
247+
g.drawString(tab.name, textLeft, baseline);
248+
}
249+
x += TAB_BETWEEN;
222250
}
223-
x += TAB_BETWEEN;
224251
}
225-
}
226252

227253

228-
private void drawTab(Graphics g, int left, int right,
229-
boolean leftNotch, boolean rightNotch) {
230-
Graphics2D g2 = (Graphics2D) g;
231-
EditorHeader.roundRect(g2, left, TAB_TOP, right, TAB_BOTTOM,
232-
0, 0,
233-
leftNotch ? CURVE_RADIUS : 0,
234-
rightNotch ? CURVE_RADIUS : 0);
235-
}
254+
private void drawTab(Graphics g, int left, int right,
255+
boolean leftNotch, boolean rightNotch) {
256+
Graphics2D g2 = (Graphics2D) g;
257+
EditorHeader.roundRect(g2, left, TAB_TOP, right, TAB_BOTTOM,
258+
0, 0,
259+
leftNotch ? CURVE_RADIUS : 0,
260+
rightNotch ? CURVE_RADIUS : 0);
261+
}
236262

237263

238-
public Dimension getPreferredSize() {
239-
return new Dimension(300, HIGH);
240-
}
264+
public Dimension getPreferredSize() {
265+
return new Dimension(300, HIGH);
266+
}
241267

242268

243-
public Dimension getMinimumSize() {
244-
return getPreferredSize();
245-
}
269+
public Dimension getMinimumSize() {
270+
return getPreferredSize();
271+
}
246272

247273

248-
public Dimension getMaximumSize() {
249-
return new Dimension(super.getMaximumSize().width, HIGH);
274+
public Dimension getMaximumSize() {
275+
return new Dimension(super.getMaximumSize().width, HIGH);
276+
}
250277
}
251278

252279

253280
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
254281

255282

256283
class Tab {
257-
String text;
284+
String name;
258285
Component comp;
286+
boolean notification;
259287

260288
int left;
261289
int right;
262290
int textWidth;
263291

264292
Tab(String name, Component comp) {
265-
this.text = name;
293+
this.name = name;
266294
this.comp = comp;
267295
}
268296

app/src/processing/app/contrib/ContributionManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ public static void downloadAndInstallOnImport(final Base base,
311311
// To avoid the user from modifying stuff, since this function is only called
312312
// during pre-processing
313313
base.getActiveEditor().getTextArea().setEditable(false);
314-
base.getActiveEditor().getConsole().clear();
314+
// base.getActiveEditor().getConsole().clear();
315315

316316
ArrayList<String> installedLibList = new ArrayList<String>();
317317

java/src/processing/mode/java/JavaEditor.java

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public void rebuild() {
206206

207207

208208
@Override
209-
public Container createFooter() {
209+
public EditorFooter createFooter() {
210210
// //JPanel consolePanel = new JPanel();
211211
// JTabbedPane footer = new JTabbedPane(JTabbedPane.BOTTOM);
212212
//// tabPane.setUI(new BasicTabbedPaneUI());
@@ -215,7 +215,9 @@ public Container createFooter() {
215215
//// tabPane.setUI(new PlasticTabbedPaneUI());
216216
//// tabPane.setBorder(BorderFactory.createEmptyBorder());
217217
//// tabPane.setBackground(Color.RED);
218-
EditorFooter footer = new EditorFooter(this);
218+
219+
// EditorFooter footer = new EditorFooter(this);
220+
EditorFooter footer = super.createFooter();
219221

220222
// Adding Error Table in a scroll pane
221223
errorTableScrollPane = new JScrollPane();
@@ -251,7 +253,8 @@ public Container createFooter() {
251253
// consoleProblemsPane.add(super.createConsolePanel(), Language.text("editor.footer.console"));
252254
// consolePanel.add(consoleProblemsPane, BorderLayout.CENTER);
253255

254-
footer.addPanel(Language.text("editor.footer.console"), new EditorConsole(this));
256+
// console = new EditorConsole(this);
257+
// footer.addPanel(Language.text("editor.footer.console"), console);
255258
footer.addPanel(Language.text("editor.footer.errors"), errorTableScrollPane);
256259

257260
//return consolePanel;
@@ -2571,7 +2574,8 @@ public void repaintErrorBar() {
25712574
public void showProblemListView(String buttonName) {
25722575
// CardLayout cl = (CardLayout) consoleProblemsPane.getLayout();
25732576
// cl.show(consoleProblemsPane, buttonName);
2574-
((JTabbedPane) consolePanel).setSelectedIndex(ERROR_TAB_INDEX);
2577+
// ((JTabbedPane) consolePanel).setSelectedIndex(ERROR_TAB_INDEX);
2578+
footer.setPanel(errorTableScrollPane);
25752579
}
25762580

25772581

@@ -2586,14 +2590,17 @@ synchronized public boolean updateTable(final TableModel tableModel) {
25862590
* the error button at the bottom of the PDE
25872591
*/
25882592
public void updateErrorToggle() {
2589-
String title = Language.text("editor.footer.errors");
2590-
if (JavaMode.errorCheckEnabled && errorCheckerService.hasErrors()) {
2591-
title += "*";
2592-
}
2593-
((JTabbedPane) consolePanel).setTitleAt(ERROR_TAB_INDEX, title);
2594-
// btnShowErrors.updateMarker(JavaMode.errorCheckEnabled &&
2595-
// errorCheckerService.hasErrors(),
2596-
// errorBar.errorColor);
2593+
footer.setNotification(errorTableScrollPane,
2594+
JavaMode.errorCheckEnabled &&
2595+
errorCheckerService.hasErrors());
2596+
// String title = Language.text("editor.footer.errors");
2597+
// if (JavaMode.errorCheckEnabled && errorCheckerService.hasErrors()) {
2598+
// title += "*";
2599+
// }
2600+
// ((JTabbedPane) footer).setTitleAt(ERROR_TAB_INDEX, title);
2601+
//// btnShowErrors.updateMarker(JavaMode.errorCheckEnabled &&
2602+
//// errorCheckerService.hasErrors(),
2603+
//// errorBar.errorColor);
25972604
}
25982605

25992606

0 commit comments

Comments
 (0)